3 ms·
JSON is syntactically valid JavaScript, why do you say it's not compatible with JavaScript?
by root_axis 4y ago
JSON is syntactically valid JavaScript, why do you say it's not compatible with JavaScript?
- krainboltgreene 4y agoNot all JSON is syntactically valid javascript.
- alexisbear 4y agoSince ES2019[1], all JSON is valid JavaScript with U+2028 and U+2029 being accepted as unescaped characters in strings. 1: https://tc39.es/proposal-json-superset/ https://tc39.es/proposal-json-superset/
- WickyNilliams 4y agoJSON is not a strict subset of JS in that `true` is valid JSON, but not a valid JS program. Might be considered a nitpick but in a thread about semantics it's worth noting
- a3w 4y agoAsk Douglas Crockford. I did not find my source on his apprehension of his name. What id did find: He states that he did plan for JSON to be a JavaScript subset, which contradicts his later finding, for which I have only me memory as a source, that JSON is not in some sense JavaScript. More on topic, I did find a source that it was never meant to be human-readable in the sense of usable for documentation, but a machine-communication language, therefore comments were removed from the initial draft to avoid having non-standard meanings put in the freedom comments allow (think pre-process directives etc.).