What is JSON (JavaScript Object Notation)?
JSON (RFC 8259) is a standard text-based format for representing structured data based on JavaScript object syntax. It is commonly used for transmitting data in web applications, REST APIs, and configuration files.
Common JSON Syntax Pitfalls and How to Fix Them
- Trailing Commas: Standard JSON does not permit commas after the last array item or object key (e.g.
[1, 2,]is invalid). - Unquoted Keys: All object property names in JSON must be double-quoted strings (e.g.
{"id": 1}vs{id: 1}). - Single Quotes: Strings in standard JSON must use double quotes (
"), not single quotes ('). - Comments: Standard JSON does not support
//or/* */comments. Use JSONC or JSON5 for comment-compatible formats.
Pretty-Printing vs. Minifying: When to Use Which
Pretty-printing formats JSON with indentation and newlines to maximize human readability during debugging and documentation. Minification strips all unnecessary whitespace to reduce byte payload size for high-throughput network APIs and LLM context windows.