5 ms·
How does json "not support comments"? {"comment":"default values for this object"}
by mSparks 10y ago
How does json "not support comments"?
{"comment":"default values for this object"}
- pilif 10y agoSince when is in-band signalling a good idea? What if one of your configuration keys is named "comment"?
- DonHopkins 10y agoAnd what do you name your second comment?
- mSparks 10y ago{"notes to self":["Don't edit config files by hand","use a decent hierarchy"]} //Http://jsoneditoronline.org
- DonHopkins 10y agoYou could even write comments as a linear RSS feed of nested OPML outlines, by converting all that XML to JSON. http://convertjson.com/xml-to-json.htm http://convertjson.com/xml-to-json.htm
- mSparks 10y agoYep, I went through the process of replacing all our XML objects into json ones about 6 years ago now. Smaller files and much easier to read, manipulate store and transfer. And while I personally quite liked XSLT, javascript is a much more flexible and reliable option.
- inimino 10y agoFor one thing, not every place where you might want a comment happens to be in an object.
- mSparks 10y agoLike where? Who for? For what purpose? I cant think of a single example that this would be useful.
- damncabbage 10y agoA list of items in an array. Some items in that list are of particular note. (Say you have 15 items in an array. For whatever reason, such as you not being in control of the expected input structure of whatever you're giving this JSON to, you have them grouped with comments at the top of each block.)
- mSparks 10y agoWhy would you want to do that in what is basically a human readable binary file and not in a readme? You seemed to stop at the for who and for what purpose. I can 'just' about see the case in something like nodeJS package.json files (that is the least of nodeJS's problems, but that's a whole other conversation). But a readme is a so much better option than having to troll through code comments.
- inimino 10y agoThe discussion above concerns why JSON isn't a good choice for configuration files. That's exactly because configuration files are not human readable binary files.
- mSparks 10y agoTBH. I find package.json files to be much much much much nicer files than configure.sh or settings.txt files, even a configure.py. And if that isn't the case for you, not like you don't have the choice.