json/5
Properties
- alias
- JSON5
JSON5 – JSON for Humans | JSON5
About
- extension to json that aims to be easier to write and maintain by hand (e.g. for config files).
- superset of json; valid JSON files will always be valid JSON5 files
- a subset of ES5; valid JSON5 files will always be valid ES5
- expands its syntax to include some productions from ECMAScript 5.1 (ES5).
My Notes
- allows
- Code/Comment (both single-line and multi-line)
- Trailing commas in objects and arrays
- Unquoted property names
- More relaxed string syntax
- allows
#Example
- json5
{ // comments unquoted: 'and you can quote me on that', singleQuotes: 'I can use "double quotes" here', lineBreaks: "Look, Mom! \ No \\n's!", hexadecimal: 0xdecaf, leadingDecimalPoint: .8675309, andTrailing: 8675309., positiveSign: +1, trailingComma: 'in objects', andIn: ['arrays',], "backwardsCompatible": "with JSON", }
- started in 2012, and as of 2022, gets >65M downloads/week, ranks in the top 0.1% of the most depended-upon packages on npm, and has been adopted by major projects like Chromium, Next.js, Babel, Retool, WebStorm, and more. It's also natively supported on Apple platforms like MacOS and iOS.