JSON5; Designed for Humans
Some of us also like to use JSON in other ways, as configuration for example. Open up that
package.json and you may wish that there was a comment or two. Quotes everywhere? Really?
- Object keys don’t need to be quoted if they’re valid identifiers. Yes, even reserved keywords are valid unquoted keys in ES5.
- Strings can be single-quoted.
- Strings can be split across multiple lines; just prefix each newline with a backslash.
- Objects and arrays can have trailing commas.
- Both inline (single-line) and block (multi-line) comments are allowed.
- Numbers can be hexadecimal (base 16), and they can also begin with a leading decimal (e.g. .5).
Aside: I still giggle like a school girl when I think of the Samsung “designed for humans” line. Check out their launch event for a reason why so many prefer an Apple launch event :/