3 ms·
He's not my Dad, but I do follow him on Mastodon... where he had this to say on the topic a few days ago: https://layer8.space/@douglascrockford/11359531618910
by anentropic 2y ago
He's not my Dad, but I do follow him on Mastodon... where he had this to say on the topic a few days ago:
https://layer8.space/@douglascrockford/113595316189101091 https://layer8.space/@douglascrockford/113595316189101091
> If the comment is important enough to be put in the text and remembered, then make it an explicit part of the data structure. That will also make it easier for tools to find it and process it in a useful way. {"comment": ...}
> Use a preprocessor tool such as jsmin to remove the commentary before passing it to a JSON parser.
I kind of wish JSON had trailing commas though
- michaelmior 2y agoJSON5 has both comments and trailing commas. Of course you can only rely on JSON5 if you're ever passing through anywhere expecting JSON. https://json5.org/ https://json5.org/
- remon 2y agoI'm not super invested in this debate one way or the other but arguing a comment should be part of your data rather than documenting what data is contained is a bizarre take on the question. Either be of the opinion it's a data format and comments are just out of scope (and using JSON for e.g. config is just a bad choice), or agree that allowing comments in JSON should be part of the spec since right or wrong it is used for config and other human edited use cases. JSON5's adoption seems to imply people are mostly on the latter side of the fence.
- anentropic 2y agoI don't find the argument incoherent at all either it's a data transfer format and comments should be stripped before transmission or the comments are part of the data model makes you have to think clearly whether the comments are just "notes to self" at authoring time, or something relevant to the consumer OTOH of course there are plenty of 'greyer' cases