JSON streaming
JSON streaming comprises communications protocols to delimit JSON objects built upon lower-level stream-oriented protocols (such as TCP), that ensures individual JSON objects are recognized, when the server and clients use the same one (e.g. implicitly coded in). This is necessary as JSON is a non-concatenative protocol (the concatenation of two JSON objects does not produce a valid JSON object). IETF defines a JSON text sequence as JSON texts each preceded by the ASCII record separator character and followed by a line feed.
JSON streaming comprises communications protocols to delimit JSON objects built upon lower-level stream-oriented protocols (such as TCP), that ensures individual JSON objects are recognized, when the server and clients use the same one (e.g. implicitly coded in). This is necessary as JSON is a non-concatenative protocol (the concatenation of two JSON objects does not produce a valid JSON object). IETF defines a JSON text sequence as JSON texts each preceded by the ASCII record separator character and followed by a line feed. {"some":"thing\n"} {"may":{"include":"nested","objects":["and","arrays"]}} The use of a newline as a delimiter enables this format to work very well with traditional line-oriented Unix tools. A log file, for example, might look like: {"ts":"2020-06-18T10:44:12","started":{"pid":45678}} {"ts":"2020-06-18T10:44:13","logged_in":{"username":"foo"},"connection":{"addr":"1.2.3.4","port":5678}} {"ts":"2020-06-18T10:44:15","registered":{"username":"bar","email":"bar@example.com"},"connection":{"addr":"2.3.4.5","port":6789}} {"ts":"2020-06-18T10:44:16","logged_out":{"username":"foo"},"connection":{"addr":"1.2.3.4","port":5678}} which is very easy to sort by date, grep for usernames, actions, IP addresses, etc. jq --compact-output . lines.json ␞{"some":"thing\n"}␊ ␞{ "may": { "include": "nested", "objects": [ "and", "arrays" ] } }␊ {"some":"thing\n"}{"may":{"include":"nested","objects":["and","arrays"]}} { "some": "thing\n" } { "may": { "include": "nested", "objects": [ "and", "arrays" ] } } Implementations that rely on line-based input may require a newline character after each JSON object in order for the object to be emitted by the parser in a timely manner. (Otherwise the line may remain in the input buffer without being passed to the parser.) This is rarely recognised as an issue because terminating JSON objects with a newline character is very common. This example shows two length-prefixed JSON objects (with each length being the byte-length of the following JSON string): 18{"some":"thing\n"}55{"may":{"include":"nested","objects":["and","arrays"]}}
References
No reference rows published for this article.
Cite this article
MLA
"JSON streaming." encyclopegia.org, 2026, https://encyclopegia.org/wiki/json-streaming. Accessed 24 November 2026.
Chicago
"JSON streaming." encyclopegia.org. Accessed November 24, 2026. https://encyclopegia.org/wiki/json-streaming.
APA
encyclopegia.org. (2026). JSON streaming. Retrieved November 24, 2026, from https://encyclopegia.org/wiki/json-streaming
Accessed November 24, 2026 · CC BY-SA 4.0 · citation page · JSON