What it looks like
JSON data is written as key-value pairs in curly braces and lists in square brackets: {"name": "Ann", "tags": ["a", "b"], "active": true}. Keys and strings always use double quotes. The six value types are string, number, true or false, null, object and array.
Why it is everywhere
It is easy for people to read and trivial for programs to parse, and almost every language can handle it. Despite the name it is not tied to JavaScript.
Rules that trip people up
- No trailing commas and no comments.
- No single quotes and no unquoted keys.
- No
undefined,NaNorInfinity.
Check yours with the JSON Validator, tidy it with the JSON Formatter, or learn more in how to format JSON.
Common misunderstanding
JSON is a data format, not a programming language, and valid JSON is not necessarily valid JavaScript object code or the other way round. See also minification for the compact form.