9 ms·
So instead of comments with parsing directives, people use underscore prefixed keys to keep metadata and comments, that's not a win at all
by gregoriol 2y ago
So instead of comments with parsing directives, people use underscore prefixed keys to keep metadata and comments, that's not a win at all
- motorest 2y ago> So instead of comments with parsing directives, people use underscore prefixed keys to keep metadata and comments, that's not a win at all Your comment doesn't make any sense. You're just pointing out that developers designed data interchange formats as subsets of JSON which explicitly support metadata and comments. This means they are specifying their schemas to support these usecases in a way clients can and do support it. That, if anything, proves right the decision to not support comments because it resulted in better-defined and well-behaving clients.
- gregoriol 2y agoComments could be skipped by parsers, instead parsers need to parse and store those keys/values that are not relevant. This is not called efficient.
- arp242 2y agoThe thing is that JSON was intended to be a data exchange format, not a configuration file format or anything else. IMHO Crockford's reasoning makes a lot more sense with that in mind.
- JambalayaJimbo 2y agoData interchange formats are often used for configuration. It makes sense to have a single source of truth in json if your configuration is consumed by an app.
- gregoriol 2y agoEven if we stick to the data exchange format, it would be practical to have comments in examples of data. This would be good for training and learning, for documentation.
- arp242 2y agoObviously it's useful in many cases; designing anything like this is an exercise in trade-offs.
- conscion 2y agoThis is still possible. There's nothing stopping you from putting comments in the JSON in your file or a webpage. It's just not going to be accepted as valid by JSON parser, which for learning material should be fine.
- layer8 2y agoXML was intended as a data exchange format and has comments. Image file formats like JPEG and PNG support comments (and so does SVG by virtue of being XML). Database systems support comments on database objects. It’s really not a convincing argument.
- hn_throwaway_99 2y agoJSON is a human-readable data exchange format. There is a good reason human-readable data exchange formats are so popular - they can be read and understood by humans! So it seems pretty absurd that a format designed to be read by humans doesn't support comments. If you're really concerned about performance or size, you should use a more efficient binary format for data exchange like protobufs, or heck, BSON (binary json)!