JSON5 and JSONC: JSON with Comments
Both dialects exist because human-written config needs comments and trailing commas, but their syntax and ecosystem reach differ, so picking wrong jams your toolchain.
JSON5, JSONC, JSON Lines and NDJSON solve real needs such as comments, trailing commas and streaming, and bring compatibility and selection problems of their own.
10 articlesBoth dialects exist because human-written config needs comments and trailing commas, but their syntax and ecosystem reach differ, so picking wrong jams your toolchain.
One JSON value per line buys you appendability, streaming, and damage isolated to a single line; the cost is the absence of overall structure, so validation has to happen line by line.
RFC 7464 uses a 0x1E separator to stream JSON texts you can read and write at once. Covers the rules, how it differs from NDJSON, and a split-then-parse implementation.
Config files need comments, dates and multi-line text, which is where JSON falls short. Compare JSON, TOML, YAML and CSON, and see what conversion always loses.
MessagePack, CBOR and BSON all compress JSON into bytes. Compare byte cost, int64 and binary handling, and get a clear line for when switching is worth it.
Feeding a whole .jsonl file to JSON.parse and getting an error almost never means the file is broken — it means the wrong reading strategy. This guide covers the standard ways to inspect and read JSONL line by line, the commands for converting to and from JSON arrays, a six-row table of common bad lines, and the correct way to consume JSONL from streaming HTTP responses.
LLM responses wrapped in markdown fences, trailing commas, and Python literals will not survive a strict parser — neither will hand-edited configs missing quotes. This guide draws the real line between nine error classes a repairer fixes and four it cannot, explains why state machines beat regex, and gives you a production-ready parse chain with jsonrepair and json-repair.
Feeding a uniform array to a large language model in JSON burns tokens on repeated key names and brackets. TOON declares the structure once with indented objects and tabular arrays, then streams row data — official benchmarks show ~40% fewer tokens and higher parse accuracy. This guide covers the syntax, when the savings apply, when not to convert, and how to wire up encode and decode.
The model returns JSON that stops mid-value, and the parser only gives you a column number. Closing the brackets makes it parse again, but every missing field is now hidden inside the data. This article draws the line between what truncation repair can honestly recover and what must be retried, from stop_reason gating to schema field ordering.
LLMs emit JSON token by token and APIs deliver big responses in chunks, but JSON.parse refuses to run until the whole document arrives. This guide separates three implementation styles — full repair, true incremental repair and partial parsing — and shows how an Allow mask keeps previews stable, backed by measured pipeline numbers and production-ready code.