The Strict Rules of JSON
JavaScript Object Notation (JSON) is the undisputed king of lightweight data-interchange formats. However, because it is designed for rapid machine parsing, it enforces strict syntax rules that easily trip up developers:
1. **Double Quotes Only**: All keys and string values must be enclosed in double quotes (`"`). Single quotes (`'`) or backticks (`` ` ``) are invalid and will cause immediate parsing failures.
2. **No Trailing Commas**: Unlike standard JavaScript objects, JSON strictly forbids a trailing comma after the final property in an object or the final element in an array.
3. **Data Types**: Allowed data types are String, Number, Object (JSON object), Array, Boolean, and Null. You cannot serialize Functions, `undefined`, or Date objects (Dates must be converted to ISO 8601 strings).
The Cost of Syntax Errors
A single misplaced comma in a massive JSON payload will cause `JSON.parse()` to throw a fatal exception. In edge environments or microservices, unhandled parse exceptions can crash entire node processes.
