Different pipes. One standard.

Type to search this site.

Search runs in your browser against a static index built with this site (Pagefind). Nothing you type is sent to a server.

TransformExperimental

std:json-format #

Serialises items as NDJSON text.

For example: hand records to a tool that reads text.

A pipe is a data processing step with declared inputs and outputs; standard pipes are built into the runner.

Ports #

std:json-format takes in and produces out.std:json-formatinrecordsouttext
std:json-format takes in and produces out.std:json-formatinrecordsouttext
Named ports from the latest published contract. Dashed lines are optional ports.
Ports of std:json-format
PortDirectionKindRequiredDescription
ininputrecordsyes
outoutputtextyes

Parameters #

This pipe has no parameters.

When to use it #

  • The next pipe has a text input and expects NDJSON: one compact JSON line per record, each ending with a newline.
  • The inverse of std:json-parse at the end of a text-to-text pipeline.

When to use something else

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.

Parameters

This test sets no parameters.

Input: in
{"a":1}
"x"
Expected output: out
{"a":1}
"x"

The same step as a node of a pipeline.yaml:

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.

Command
printf '%s\n' '{"a":1}' '"x"' | openflange run std:json-format
Standard output (out)
{"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