JSON Syntax Rules
- Data is in key-value pairs:
"key": "value" - Keys must be strings in double quotes
- Values can be: string, number, boolean (true/false), null, object {}, or array []
- No trailing commas after the last item
- No comments (unlike JavaScript)
- No single quotes—only double quotes for strings
Common JSON Errors
| Error | Wrong | Correct |
|---|---|---|
| Single quotes | {'name': 'John'} | {"name": "John"} |
| Trailing comma | {"a": 1, "b": 2,} | {"a": 1, "b": 2} |
| Unquoted key | {name: "John"} | {"name": "John"} |
| undefined | {"val": undefined} | {"val": null} |