Why can't we have a trailing comma in JSON? Why doesn't it support inline comments. Why can't we single quote things? Why do we need to double quote keys?<p>JavaScript objects are similar to JSON and allow all this and it works just fine. They never misinterpret anything.<p>So why can't JSON be more forgiving? I remember XML used to be the same back in the day.<p>Why do creators of schema make them so strict? Isn't the whole thing about making life of users (or devs in the case) easier? What purpose does such fussy specifications achieve?
JSON parsing is hard enough, don't make it harder.<p>> Why do creators of schema make them so strict? Isn't the whole thing about making life of users (or devs in the case) easier? What purpose does such fussy specifications achieve?<p>No, the purpose is correctness. It prevents you from writing malformed structures, allows machines to automatically check for correctness, and downstream programs to make assumptions about its correctness without errors.<p>JSON is machine readable first, human readable second, machine writeable third, and human writeable last. It makes sense not to prioritize writing it by hand.<p>Most of the time if you are writing JSON by hand, you've screwed something up.
The whole point of a defined data standard is to remove ambiguities in sender/receiver implementations. It may be strict, but that makes it easier to write a parser for, and easier for multiple different projects to get right.
Trailing commas have only been allowed in Javascript object literals since ECMAScript 5 in 2009 — JSON dates from 2001.<p>Re comments, Crockford said: "I removed comments from JSON because I saw people were using them to hold parsing directives, a practice which would have destroyed interoperability." See: <a href="https://archive.ph/20150704102718/https://plus.google.com/+DouglasCrockfordEsq/posts/RK8qyGVaGSr" rel="nofollow">https://archive.ph/20150704102718/https://plus.google.com/+D...</a>
Have you taken a look at CUE? It might be what you are looking for and more!<p><a href="https://cuelang.org" rel="nofollow">https://cuelang.org</a> | <a href="https://cuetorials.com" rel="nofollow">https://cuetorials.com</a>
Its grammar is extremely simple, which effectively neutralizes issues with parsers interpreting it differently or having unexpected behaviour which is in line with spec (like yaml or xml).
The answer is in its name: JSON stands for JavaScript Object Notation (JSON). It is a standard text-based format for representing structured data based on JavaScript object syntax. It follows me rules of what is possible to do in JavaScript and, if I recall correctly, the reason was that originally it was a feature to be able to drop JSON data into eval…
On a related note, when in interactive mode, I wish Python would double quote instead of single quote strings when printing their representation<p>>>> {"test":4}<p>{'test': 4}