3 ms·
Do checkout http://json5.org/ http://json5.org/ based off the original JSON author Doug Crockford's own proposed parser extensions, primarily trailing commas an
by aleem 10y ago
Do checkout http://json5.org/ http://json5.org/ based off the original JSON author Doug Crockford's own proposed parser extensions, primarily trailing commas and comments, both of which have been a point of contention pretty much the day since the day JSON landed. It's a much simpler and saner proposal.
Trailing commas and JSON comments are are already supported in the newer browsers (try the Chrome console for instance).
Fortunately quoteless strings or optional-commas/newline-separator as proposed in Hjson will never fly. They are brittle and ambiguous. Who knows what will this get parsed as:
{
a: hello's and hi's have
'misplaced' apostrophes
b: ball: a round # and # bouncy object
c: cakes and
candy: both have sugar
# but how do I include a hash at the start of a multiline-unquoted string?
}
- masklinn 10y ago> Trailing commas and JSON comments are are already supported in the newer browsers (try the Chrome console for instance). Version 49.0.2623.112 (64-bit) > JSON.parse('{"foo": "bar",}') > VM124:1 Uncaught SyntaxError: Unexpected token } Javascript object literals != JSON. JSON is a restricted subset of JS object literals (and not actually a strict subset: a JSON string can contain unescaped U+2028 "LINE SEPARATOR" and U+2029 "PARAGRAPH SEPARATOR" codepoints, a Javascript string can not)