5 ms·
The killer feature for me over JSON is comment support, it's definitely useful to add todo comments etc.
by bamboozled 8y ago
The killer feature for me over JSON is comment support, it's definitely useful to add todo comments etc.
- abraae 8y agoYep, so true. Any decent config file that will be seen/edited by a human needs comment support. And any file that will not be seen by a human could be json (or whatever).
- krferriter 8y agoYeah this is a huge selling point of YAML. JSON should have comments added to the spec. The other benefit to YAML is human readability, which is usually better in YAML compared to JSON. A specific glaring example of this is when there are long string-literal snippets inside the document, in YAML this is massively more readable than in JSON.
- hannasanarion 8y agoJSON shouldn't have comments added to the spec, because people shouldn't be trying to read or write JSON. It's an application interchange language, meant to be written and read by machines. YAML is a markup language, meant to be written and read by people. Ever notice how most YAML libraries don't even have a "dump" function?
- krapp 8y ago>It's an application interchange language, meant to be written and read by machines. Not entirely true, JSON is based on Javascript objects, it was meant to be written and read by humans just like Javascript, INI or any other basic serialized data format, or text-based programming language. If JSON were truly never meant to never be viewed or edited by human beings, it would have been published as bytecode.
- heavenlyblue 8y ago>> Ever notice how most YAML libraries don't even have a "dump" function? No. I guess unless you’re using something half-baked, I suppose. Machines need to be able to edit configs either way.
- marcosdumay 8y agoHum... We have a bad historic of success in deciding that this or that stuff is for machine consumption only.
- lstamour 8y ago> JSON should have comments added to the spec. See also ~5 years ago: https://news.ycombinator.com/item?id=7325735 https://news.ycombinator.com/item?id=7325735
- basil-rash 8y agoYou can just use JSON with comments though. If you have sufficient control over the technology in question to be able to completely change it to a YAML parser, surely you can change it to be a JSON+Comment parser too. See: VS Code's config files.
- jhanschoo 8y agoBut you can restrict yourself to JSON+Comments and call it YAML; it isn't idiomatic YAML, but it's still valid YAML.
- saagarjha 8y ago> You can just use JSON with comments though. Then it's not valid JSON, and if you try to treat it as such bad things will happen.
- basil-rash 8y agoMy point is that if you're in sufficient control of the stack to be able to convert the whole thing over to YAML, you could just as easily convert the whole thing over to JSON+Comments. And of course bad things would happen if you treat JSON+Comments as JSON, but similar bad things would happen if you treat YAML as JSON, so I don't see your point. It's not like people are trying to send their tsconfig's on the wire as "application/json" and expecting arbitrary parsers to support it.
- h1d 8y agoWhen you think about it, JSON lacks so much (check JSON5 for what it's lacking), it's hard to believe even a comment is not allowed when pretty much anything else allows, which is a showstopper by itself.