JSON streaming

Frequently there's a need for a stream of objects to be sent over a single connection, such as a stock ticker or application log records.

It doesn't work well with traditional line-oriented tools, but may offer performance advantages over line-delimited or concatenated streaming.

A log file, for example, might look like: which is very easy to sort by date, grep for usernames, actions, IP addresses, etc.

In the past the NDJ specification ("newline-delimited JSON")[8] allowed comments to be embedded if the first two characters of a given line were "//".

Current version of the specification ("NDJSON - Newline delimited JSON ")[9] no longer includes comments.

It relies on the receiver using a parser that can recognize and emit each JSON object as the terminating character is parsed.

Length-prefixed or framed JSON streaming allows the sender to explicitly state the length of each message.

The advantage of this format is that it can speed up parsing due to the fact that the exact length of each message is explicitly stated, rather than forcing the parser to search for delimiters.