JSON is a text format for structured data. A file is valid only if it follows a small set of strict rules.
Structure
- Objects use curly braces: { "key": "value" }
- Arrays use square brackets: [1, 2, 3]
- Keys must be in double quotes
- Items are separated by commas, with no comma after the last one
Value types
- String: "text" in double quotes
- Number: 42 or 3.14, with no quotes
- Boolean: true or false
- Empty value: null
Common mistakes
- Single quotes are not valid JSON
- Trailing commas are not allowed
- Comments are not allowed
- undefined is not a JSON value