4 ms·
The only thing I miss from XML is the ability to comment out something. I discovered the other day that it wasn't apparently possible.
by thibaut_barrere 16y ago
The only thing I miss from XML is the ability to comment out something. I discovered the other day that it wasn't apparently possible.
- davepeck 16y agoFormats targeted strictly at machine/machine interchange ultimately get used for much more. JSON is no exception. Configuration tends to be the first place that interchange formats are "abused"; even for such a mild abuse, comments are essential. (Hard-core abuses, like XML-based programming languages, are another thing entirely. :-) To deal with JSON's lack of comments, I've considered writing services and apps that produce JSON, but consume YAML. Here, the interesting qualities of YAML are (1) it's a superset of JSON, and (2) it supports comments.
- KaeseEs 16y agoYAML isn't a strict superset of JSON, although since YAML 1.2 it is very nearly so; with just a little bit of care you can avoid the edge cases (eg. you can have hash keys longer than 1024 characters in JSON but not in YAML), provided you are cognizant of them.
- deleted 16y ago[deleted]
- viraptor 16y agoI'm quite surprised. What did you need the comments for?
- thibaut_barrere 16y agoI had a chef json configuration file which I was creating and testing as I went. In this file I had to remove 3 "recipes" and one "attribute" temporarily. Because of the lack of comments I copied the old version to a new file etc.
- axod 16y agoIf you don't care about the standard, you can use / * * / to comment out stuff in JSON. It's a shame this wasn't in the spec. Along with making quotes optional for keys. It's a real shame that the native JSON object, and the spec missed out these useful features... var obj = eval("({foo:3 /*,bar:7*/ })"); Works fine, but JSON.parse and probably most other JSON libs throw a hissy fit for no good reason. I love JSON, but making quotes compulsory for keys, and missing out comments are both a PITA.