Skip to main content

JSON Stream Parser

JSON Stream Parser: turns stream fragments into JSON values as NDJSON, concatenated values, or one whole document.

Each parse appends the current chunk to a buffer and extracts whatever is now complete. 'NDJSON' takes one value per line and reports a line that does not parse rather than skipping it silently. 'Stream' accepts any concatenation of complete top-level values — whitespace-separated objects, or a JSON array whose elements are emitted as they close — and is safe at every chunk boundary, including one that falls inside a string. 'Single document' holds everything back until the whole buffer is one complete value, then emits it. Text that is not yet a complete value stays in the buffer and shows on pendingCharacters; maxLength stops a malformed stream from growing without bound by clearing the buffer and reporting it. values carries everything the last parse completed, parsed the last of them.

When to use it​

A stream whose payloads are JSON but do not arrive one-per-event: NDJSON logs, a chunked HTTP body, an array streamed element by element. Not needed for Server-Sent Events with one JSON object per event — that node already parses each payload onto its Data output.

At a glance​

CategoryData
Type namenet.noodl.JSONStreamParser
Available inbrowser, cloud
SSR compatibilitysafe
Provided bynoodl-runtime

Inputs​

Values​

NameTypeDefaultDescription
chunkString—The next fragment of the stream; boundaries may fall anywhere, including inside a string
formatEnum (ndjson, stream, single)ndjsonHow values are framed on this stream: one per line, any concatenation of complete values, or one whole document
maxLengthNumber1048576Cap on unparsed text held while a value completes; exceeding it clears the buffer and reports an error rather than growing forever

Signals​

NameTypeDefaultDescription
clearSignal—Discards the pending text, the parsed values and the error counter
parseSignal—Appends the current Chunk and emits every value that is now complete; the chunk is retained between pulses

Outputs​

Values​

NameTypeDefaultDescription
isCompleteBoolean—True when the last Parse left nothing pending, so every value so far was whole
parsed*—The last complete value the most recent Parse produced
pendingCharactersNumber—Text held back because a value is not complete yet; persistently non-zero means Format does not match the stream
valueCountNumber—How many values have been parsed since the last Clear, across every Parse
valuesArray—Every value completed by the most recent Parse, in order

Signals​

NameTypeDefaultDescription
clearedSignal—Fires once the pending text and the values have been discarded
completedSignal—Fires after every invocation, whatever the outcome — wire this to carry on regardless. Failure still fires and still carries its reason, so this cannot hide an error
doneSignal—Fires when a Parse consumed text or a Clear discarded something; Success is narrower and fires only when values came out
successSignal—Fires when a Parse yielded at least one value, so a chunk that merely advanced an incomplete value stays quiet
unchangedSignal—Fires when there was nothing pending to parse, or nothing to clear — a valid action with nothing to do

Failure outputs​

NameTypeDefaultDescription
errorString—Why the last value or line would not parse; kept until the next failure or a Clear
errorCountNumber—How many values have failed to parse since the last Clear
failureSignal—Fires once when a Parse could not read part of its input, or when the pending text exceeded Max Pending; Error Count says how many

Patterns​

  • Server-Sent Events data → chunk, onMessage → parse, format NDJSON: a log stream that arrives several lines per event.
  • values → For Each items renders everything a chunk completed, instead of only the last value.
  • pendingCharacters on a debug Text output makes a format mismatch obvious instead of looking like a dead stream.

Watch out for​

  • Using 'Single document' on a never-ending stream — the buffer grows until Max Pending trips.
  • Reading only parsed when a chunk can complete several values; the earlier ones are then silently ignored.
  • Adding this after Server-Sent Events when each event is already one JSON object — the SSE node's Data output has parsed it.

Examples​

Long-running task monitor: progress, batched log lines, and a visible connection

A backend job streams two kinds of frame on one connection. Pattern Extractor pulls the percentage out of human-readable status text, so a progress bar tracks it without a Function node. JSON Stream Parser turns NDJSON log payloads into values — several may complete in one frame, so values rather than parsed is what feeds downstream. Stream Buffer batches those into a flush every 250 ms, which keeps a busy log from repainting the list hundreds of times a second, and the stream's onClose flushes the tail that never reached a full batch.

Server-Sent Events, Text Accumulator, Stream Buffer, REST

Generated

This page is generated from node-catalog-enriched.json. Do not edit it by hand — run npm run docs:nodes to regenerate, and fix the source enrichment instead.