3 ms·
Comments do have a place in a data format if the format is intended to be human readable.
by azeirah 10y ago
Comments do have a place in a data format if the format is intended to be human readable.
- natch 10y agoI think JSON is intended to strike the right balance between readability by machines (primary goal) and readability by humans (secondary). Comments don't make sense to the machine and are just overhead. And they tend to be abused or extended in hacky ways. So I'm glad they're not there.
- Klathmon 10y agoTo expand on what the other commenter said. The creator of JSON was explicitly against comments for a few reasons. The biggest one was that comments are often used to "extend" a format. Look at doc-block, annotations, etc... In order for the format to work, everyone had to use the exact same set of rules, and that meant that if people started adding their own "crap" to the format in a "backwards compatible" way you'd lose what makes it special. So he didn't add comments. And I personally think it worked out.
- azeirah 10y agoAh ok, I hadn't considered that, that's quite clever really.
- dv_dt 10y agoSo now lots of JSON parsers have extensions to ignore comment extensions to the format...
- legutierr 10y agoThis argument against the inclusion of comments is a good argument in favor of the inclusion of a date data type and a binary data type. Right now, there are a number of different ways to encode both types of data, and you see them all in the wild. And extra custom serialization and deserialization steps are always required to handle them.