Ports #
| Port | Direction | Kind | Required | Description |
|---|---|---|---|---|
in | input | text | yes | |
out | output | records | yes |
Parameters #
This pipe has no parameters.
When to use it #
- A pipe or an input gives you text that contains one JSON value per line: turn it into records for the pipes that follow.
- Fail early on a broken file: a blank line or a line that is not JSON stops the run with
E_FORMAT.
When to use something else
- For CSV text use
std:csv-decode.
A tested example #
Nothing here is invented: this is the test “parses lines and preserves literals” from the pipe's own portable test file, which every conformant runner must pass.
This test sets no parameters.
{"n":1.50}
"two"
3{"n":1.50}
"two"
3The same step as a node of a pipeline.yaml:
nodes:
json-parse:
pipe: std:json-parse
inputs:
in: {from: inputs.in}This input is not plain records. A standalone pipeline.yaml cannot declare the kind of its inputs, so this node belongs in a pipe whose manifest declares the input in with kind text, or after a node that produces that kind.
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 '{"n":1.50}\n"two"\n3' | openflange run std:json-parse{"n":1.50}
"two"
3Executed 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 a text stream to JSON items. The text is
NDJSON: one JSON value per \n-terminated line. Lines may span text chunks;
a missing final newline is tolerated. Each value is kept as its original
bytes, so number literals are preserved.
Blank lines, invalid JSON, invalid UTF-8, a byte order mark, or a line longer
than 64 MiB fail the run with E_FORMAT (naming the line). Inverse of
std:json-format.
Reference #
- Maturity
- Experimental
- Processing scope
record- Manifest version
0.1.0
- Normative definition: std:json-parse in the standard library specification
- Manifest and tests: std/0.1/json-parse in the specification repository