3 ms·
> you'll still have trouble reinserting those comments when writing JSON. Sure. I wouldn't even try. > And if you don't have that, you have a config file whic
by jolmg 7y ago
> you'll still have trouble reinserting those comments when writing JSON.
Sure. I wouldn't even try.
> And if you don't have that, you have a config file which can only be read, not written.
Just like most config files.
> And if you accept that, then what was the point of using JSON in the first place?
To not define your own format and be able to use ready-made parsers.
It's not like I'm advocating for the use of JSON over other choices like YAML. I'm just replying to a comment about how to add comments to a JSON with a better alternative. If someone wants to use JSON over other choices for whatever reason and the only thing holding them back is the lack of comments, then this is a valid way to add comments, I believe.
If you use a string property, you can't split your comment among multiple lines. You could perhaps do an array of strings or something, but I think adding a simple commenting syntax like this is neater.
EDIT: Fixed double negative in penultimate paragraph.