JSON
JSON (JavaScript Object Notation, pronounced ; also ) is an open standard file format and data interchange format that uses human-readable text to store and transmit data objects consisting of attribute–value pairs and arrays (or other s ...
streaming comprises
communications protocol
A communication protocol is a system of rules that allows two or more entities of a communications system to transmit information via any kind of variation of a physical quantity. The protocol defines the rules, syntax, semantics and synchro ...
s to
delimit
A delimiter is a sequence of one or more characters for specifying the boundary between separate, independent regions in plain text, mathematical expressions or other data streams. An example of a delimiter is the comma character, which acts a ...
JSON
JSON (JavaScript Object Notation, pronounced ; also ) is an open standard file format and data interchange format that uses human-readable text to store and transmit data objects consisting of attribute–value pairs and arrays (or other s ...
objects built upon lower-level stream-oriented protocols (such as
TCP
TCP may refer to:
Science and technology
* Transformer coupled plasma
* Tool Center Point, see Robot end effector
Computing
* Transmission Control Protocol, a fundamental Internet standard
* Telephony control protocol, a Bluetooth communication s ...
), 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).
Introduction
JSON is a popular format for exchanging object data between systems. Frequently there's a need for a stream of objects to be sent over a single connection, such as a
stock ticker
Ticker tape was the earliest electrical dedicated financial communications medium, transmitting stock price information over telegraph lines, in use from around 1870 through 1970. It consisted of a paper strip that ran through a machine called a ...
or
application log records. In these cases there's a need to identify where one JSON encoded object ends and the next begins. Technically this is known as
framing.
There are four common ways to achieve this:
* Send the JSON objects ''formatted without newlines'' and use a newline as the delimiter.
* Send the JSON objects concatenated with a
record separator control character as the delimiter.
* Send the JSON objects concatenate