{
  "id": "enwiki-001367461180",
  "slug": "json-streaming",
  "title": "JSON streaming",
  "qid": "",
  "lead": "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.",
  "body": "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\"]}}",
  "categories": [
    "104341943",
    "20313012",
    "22985424",
    "23118434",
    "23603337",
    "24745126",
    "26493388",
    "31347309",
    "62888473",
    "98336878"
  ],
  "license": "CC BY-SA 4.0",
  "source_uri": "https://en.wikipedia.org/w/index.php?oldid=1367461180",
  "content_hash": "",
  "created_at": null,
  "updated_at": 1785730012.0,
  "claims": [],
  "contradictions": [],
  "confidence": 0.6,
  "csl": {
    "id": "enwiki-001367461180",
    "type": "webpage",
    "title": "JSON streaming",
    "author": [
      {
        "family": "Anticloud FZ LLE",
        "literal": "Anticloud FZ LLE"
      }
    ],
    "container-title": "encyclopegia.org",
    "publisher": "Anticloud FZ LLE",
    "publisher-place": "Dubai, United Arab Emirates",
    "URL": "https://encyclopegia.org/a/json-streaming",
    "issued": {
      "date-parts": [
        [
          2026,
          11,
          19
        ]
      ]
    },
    "accessed": {
      "date-parts": [
        [
          2026,
          11,
          19
        ]
      ]
    },
    "license": "CC BY-SA 4.0",
    "DOI": "eo1:enwiki-001367461180",
    "isBasedOn": "https://en.wikipedia.org/w/index.php?oldid=1367461180",
    "note": "Immutable snapshot enwiki-001367461180"
  }
}