The JSON Standard (RFC 8259) & Modern Web API Best Practices
The JSON (JavaScript Object Notation) format, standardized under RFC 8259 and ECMA-404, is the global language of internet data exchange. It superseded XML as the dominant format for REST, GraphQL, and microservice communication due to its compact syntax, human readability, and seamless deserialization across every modern language.
1. Strict Syntactic Rules of RFC 8259 JSON
Unlike loose JavaScript object literals, standard JSON enforces strict rules that every API consumer must respect:
- Mandatory Double Quotes: All object property keys must be surrounded by double quotation marks (
"name": "value"). Single quotes ('key') or unquoted tokens trigger instant syntax errors. - No Trailing Commas: Commas following the final element of an array or object (e.g.
{"a": 1, "b": 2,}) are prohibited and will be rejected by standard parsers. - Primitive Value Support: Only six basic types are allowed: Strings, Numbers (integer or floating point), Booleans (
true/false),null, Objects ({}), and Arrays ([]). Values such asundefined,NaN,Infinity, or functions cannot be serialized.
2. Common JSON Syntax Errors & How to Fix Them
| Syntax Error Message | Root Cause | Resolution |
|---|---|---|
| Unexpected token ' in JSON | Single quotes were used instead of double quotes for keys or strings. | Replace all single quotes (') with double quotes ("). |
| Unexpected token } in JSON | A trailing comma was left before the closing curly brace. | Remove the comma after the final property. |
| Unexpected end of JSON input | Incomplete payload, missing closing bracket (]) or brace (}). |
Check hierarchy nesting and close all open structures. |
| Loss of BigInt Precision | 64-bit integer IDs larger than 2^53 - 1 (9,007,199,254,740,991). |
Serialize 64-bit database IDs as strings in API responses. |