JSON Data Types
JSON supports six value types: strings (in double quotes), numbers (integer or decimal), booleans (true or false), null, arrays (ordered lists in square brackets), and objects (key-value pairs in curly braces).
All keys must be strings and must use double quotes. Values can be any of the six types, including nested objects and arrays.
Common Syntax Errors
Single quotes around keys or values (JSON requires double quotes). Trailing commas after the last element in an array or object. Comments — JSON does not support // or /* */ comments. Unquoted keys. Numbers with leading zeros (e.g., 007 is invalid). Control characters in strings that are not properly escaped.
Formatted vs Minified JSON
Formatted JSON (also called beautified or pretty-printed) uses indentation and line breaks to make the structure readable. It is useful during development, debugging, and in version-controlled config files.
Minified JSON removes all unnecessary whitespace to reduce file size. Minified JSON is typically used in production API responses and stored data where every byte matters.
When to Validate
Always validate JSON before using it in production. A single missing comma or unclosed bracket causes the entire parse to fail. Most languages throw a parse error with a position hint — paste the JSON into a formatter to pinpoint the exact location.