JSON Format Cheatsheet
Complete JSON reference: syntax, data types, structures, parsing, and validation.
| Concept | Description | Syntax | Example | Category |
|---|---|---|---|---|
| Object | Collection of key-value pairs | { "key": value } | { "name": "John", "age": 30 } | Structure |
| Array | Ordered list of values | [ value1, value2 ] | [ 1, 2, 3 ] or [ "a", "b", "c" ] | Structure |
| String | Text value with quotes | "text" | "Hello World" | Data Types |
| Number | Integer or float | 123 or 45.67 | 42 or 3.14159 | Data Types |
| Boolean | True or false | true | false | { "active": true } | Data Types |
| Null | Empty or no value | null | { "value": null } | Data Types |
| Nested Object | Object within object | { "key": { } } | { "user": { "name": "John" } } | Structure |
| Nested Array | Array within array | [ [ ], [ ] ] | [ [1, 2], [3, 4] ] | Structure |
| JSON.parse() | Convert string to object (JS) | JSON.parse(jsonString) | const obj = JSON.parse('{"a": 1}') | Parsing |
| JSON.stringify() | Convert object to string (JS) | JSON.stringify(object) | const str = JSON.stringify({a: 1}) | Parsing |