Ports #
| Port | Direction | Kind | Required | Description |
|---|---|---|---|---|
in | input | records | yes | |
out | output | text | yes |
Parameters #
This pipe has no parameters.
When to use it #
- The next pipe has a
textinput and expects NDJSON: one compact JSON line per record, each ending with a newline. - The inverse of
std:json-parseat the end of a text-to-text pipeline.
When to use something else
- For a spreadsheet user,
std:csv-encodewrites CSV.
A tested example #
Nothing here is invented: this is the test “one line per item with a final newline” from the pipe's own portable test file, which every conformant runner must pass.
This test sets no parameters.
{"a":1}
"x"{"a":1}
"x"The same step as a node of a pipeline.yaml:
nodes:
json-format:
pipe: std:json-format
inputs:
in: {from: inputs.in}Run it #
The pipe runs on its own from a shell. The input is the test input above. The quickstart shows how to get the openflange command.
printf '%s\n' '{"a":1}' '"x"' | openflange run std:json-format{"a":1}
"x"Executed with openflange 0.0.1 (go1.27.1 linux/amd64), built from commit 11cf8cc of the reference implementation; the output shown is what it printed, and it matches the test.
Notes from the manifest #
The pipe's manifest, OPENFLANGE.md, carries these notes.
Part of the OpenFlange standard library (std, version 0.1).
The explicit conversion from JSON items to a text stream: every item
becomes one compact line followed by \n (the final newline is always
written). Insignificant whitespace is removed; everything else — number
literals, member order, string escapes — is copied byte for byte. An empty input produces an
empty text stream. Inverse of std:json-parse.
Reference #
- Maturity
- Experimental
- Processing scope
record- Manifest version
0.1.0
- Normative definition: std:json-format in the standard library specification
- Manifest and tests: std/0.1/json-format in the specification repository