JSON has an astonishingly small grammar — you can learn all of it in one sitting. Everything is built from just two containers (object and array) holding six kinds of values. Let's meet them all, live.
An object is wrapped in curly braces { }. Inside, you list
"key": value pairs separated by commas. Keys are always double-quoted strings.
An array is wrapped in square brackets [ ] and holds values in order,
separated by commas. The items can be anything — even objects or other arrays.
Any value in JSON is exactly one of these. The colours below match the output panels everywhere in this site:
| Type | Looks like | Notes |
|---|---|---|
| String | "hello" | Always double quotes. Use \n, \", \\ for escapes. |
| Number | 42, -3.14, 2e3 | No quotes. Integer or decimal. No NaN/Infinity. |
| Boolean | true, false | Lowercase, no quotes. |
| Null | null | Represents "no value". Lowercase, no quotes. |
| Object | { "k": v } | Unordered key/value pairs. |
| Array | [ v, v ] | Ordered list of values. |
[ ] creates a(n)…{ } = object.