JSON

Working with JSON

The format is small enough to learn in an afternoon and subtle enough to lose data in production. These are the parts that catch people out.

JSON earns its place by being tiny. The entire grammar fits on a single page — json.org draws it as six railroad diagrams, and RFC 8259 is a twenty-minute read, and ECMA-404 says the same thing again in fewer pages still. That is the whole appeal: any two systems can agree on it without a meeting.

The trouble starts with what the grammar leaves out. There are no comments, so configuration written in JSON has nowhere to explain itself. There is no date type, so every team invents one. And numbers are specified as decimal literals with no stated limit, which sounds generous until you notice that JSON.parse hands you a double. Anything past Number.MAX_SAFE_INTEGER comes back rounded, silently — no exception, no warning, just a different number than the one that was sent. If your identifiers are 19 digits long, and SIM and account numbers usually are, that is a live bug.

The second thing that catches people is that the syntax is unforgiving in a way its size does not prepare you for. A trailing comma after the last element is legal in JavaScript source and illegal in JSON, which is why so much hand-edited configuration fails to load. Single quotes are not string delimiters. Neither is a bare word. The parser is right and the file is wrong, and the error message rarely says so in those terms — it names a character offset and leaves you to count.

The articles below take those one at a time, with the actual payload and the actual error text rather than a description of it. If you have a file in front of you right now, JSON to Table will show you its shape faster than reading it will.

JSON articles

JSON tools on this site

All categories