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
chunkStringThe 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
clearSignalDiscards the pending text, the parsed values and the error counter
parseSignalAppends the current Chunk and emits every value that is now complete; the chunk is retained between pulses

Outputs

Values

NameTypeDefaultDescription
isCompleteBooleanTrue when the last Parse left nothing pending, so every value so far was whole
parsed*The last complete value the most recent Parse produced
pendingCharactersNumberText held back because a value is not complete yet; persistently non-zero means Format does not match the stream
valueCountNumberHow many values have been parsed since the last Clear, across every Parse
valuesArrayEvery value completed by the most recent Parse, in order

Signals

NameTypeDefaultDescription
clearedSignalFires once the pending text and the values have been discarded
completedSignalFires 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
doneSignalFires when a Parse consumed text or a Clear discarded something; Success is narrower and fires only when values came out
successSignalFires when a Parse yielded at least one value, so a chunk that merely advanced an incomplete value stays quiet
unchangedSignalFires when there was nothing pending to parse, or nothing to clear — a valid action with nothing to do

Failure outputs

NameTypeDefaultDescription
errorStringWhy the last value or line would not parse; kept until the next failure or a Clear
errorCountNumberHow many values have failed to parse since the last Clear
failureSignalFires 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 datachunk, onMessageparse, 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.