Module ndjson
Expand description
Newline-delimited JSON (NDJSON / JSON Lines) output emitter.
Each row is serialized as its own line of compact JSON, terminated by
\n. Consumers stream-parse line-by-line — LSP integrations, CI log
pipelines, and jq -c filters can react as analyses complete rather
than waiting for the closing ] of a JSON array.
Spec: https://github.com/ndjson/ndjson-spec
Each line is a complete JSON object on its own; lines are independent.
No trailing newline after the final row (also valid NDJSON; many
consumers strip it anyway). UTF-8 throughout. Numbers are emitted via
serde_json’s default f64/i64 encoding — same shape as the
batch json emitter.
Existing json.rs writers all expand to serde_json::to_writer_pretty(w, rows) over a &[T: Serialize] slice. The NDJSON shape iterates the
same slice and emits one compact object per row. No new row types —
the same HotspotRow / CodeHealthRow / etc serialize identically;
only the framing changes.
Functions§
- write_
ndjson - Generic NDJSON writer. Each
rowis emitted viaserde_json::to_writer(compact form) followed by\n.