Spécification JSON5
JSON5 est un superset de JSON enabling comments, trailing commas, unquoted clés, et plus relaxed syntax.
Syntax Extensions
JSON5 allows single and multi-line comments using // and /* */ syntax. Object keys may be unquoted if they are valid identifiers. Strings can use single quotes in addition to double quotes. Trailing commas in arrays and objects are permitted. Numbers support hexadecimal notation, leading/trailing decimal points, and positive/negative infinity.
- comments
- Single and multi-line
- unquoted keys
- Valid identifiers
- hex numbers
- Hexadecimal notation
// line /* block */ { key: 1 } 0xFF Compatibility and Parsing
Every valid JSON document is also valid JSON5, ensuring backward compatibility. JSON5 parsers are available for JavaScript, Python, and other languages. The format is primarily intended for human-edited configuration files, not data interchange. JSON5 is not an official standard but is widely adopted in tooling. For machine-to-machine exchange, standard JSON remains preferred.
- superset
- Valid JSON is valid JSON5
- use case
- Config files, not interchange
- parsers
- Available in many languages
backward compatible human-edited npm: json5