JSON isn’t the friendliest to write. Keys need to be quoted, objects and arrays can’t have trailing commas, and comments aren’t allowed — even though none of these are the case with regular JavaScript today.
JSON5 is a proposed extension to JSON that allows these kinds of things. Here’s an example showcasing most of its features:
{
foo: 'bar',
while: true,
this: 'is a \
multi-line string',
// this is an inline comment
here: 'is another', // inline comment
/* this is a block comment
that continues on another line */
hex: 0xDEADbeef,
half: .5,
delta: +10,
to: Infinity, // and beyond!
finally: 'a trailing comma',
oh: [
"we shouldn't forget",
'arrays can have',
'trailing commas too',
],
}
Note that the JSON5 proposal is in no way official (technically a new MIMEType
is required), and – I fear – most likely won’t get that much adoption/traction with things like YAML already floating around…