4 ms·
There are 3 mutually conflicting goals of JSON: 1. Machine parsing/generation 2. Human parsing/generation 3. Ability to transmit it in a parsable format t
by cube13 14y ago
There are 3 mutually conflicting goals of JSON:
1. Machine parsing/generation
2. Human parsing/generation
3. Ability to transmit it in a parsable format through HTTP
#1 conflicts with both #2 and #3. It conflicts with #1 because binary data formats are much easier to parse, and are generally smaller on the wire than plain text formats. Also, it conflicts with #3 for the same reason, since HTTP is a plain text format, and JavaScript generally deals with plain text better than binary data.
#2 conflicts with #3, because comments are nice for human readability, but should never be sent on the wire, because they are not necessary to parse the sent data. If your comment is important, it should be a data element that's sent on the wire.
The end result is a compromise. Since two of the concerns effectively make comments useless, the compromise should be towards those two. In addition, the reason given by Crockford makes quite a bit of sense. JSON, much like XML, is a format for the transmission of data. Everything in a given JSON object should be important. It's not a programming language, which means that control directives are unnecessary.