3 ms·
That example is fine, but you wouldn't want a long comment getting loaded into memory because the parser doesn't know any better.
by MatthewPhillips 13y ago
That example is fine, but you wouldn't want a long comment getting loaded into memory because the parser doesn't know any better.
- kstenerud 13y agoWhy not? It's just a configuration file.
- dnautics 13y agofor that matter, just do: { "comment":"this is a comment"; "value": 45; "comment":"this is also a comment"; "value2": 64; "comment":"we like overloading the comment field"; "stringval":"but these stay the same"; }
- IanCal 13y agoThen the parser might fail, and rightly so. A comment lower down shows it failing in a simple parser in go: https://news.ycombinator.com/item?id=6147478 https://news.ycombinator.com/item?id=6147478 Keys SHOULD be unique.
- dnautics 13y agoSHOULD != SHALL And, no, this scheme doesn't break the go parser because there isn't a typeshift between the "comment" fields, they are all strings. http://play.golang.org/p/bxcIIyAeph http://play.golang.org/p/bxcIIyAeph
- IanCal 13y agoAh fair enough on the break, I was wrong there. But if the spec says that keys SHOULD be unique, what's the behaviour when they aren't?
- dnautics 13y agoI would agree it's very hackey and probably not a good idea since the spec is liable to change. But I wouldn't be sad if the spec were changed to allow for this, or to allow for comments.
- IanCal 13y ago> I would agree it's very hackey and probably not a good idea since the spec is liable to change Well it's not really about the spec changing, the spec doesn't have a defined behaviour for duplicate keys. > But I wouldn't be sad if the spec were changed to allow for this, or to allow for comments. I don't think duplicate keys should be allowed, but I've no strong feelings on comments. I don't think there's any real need for them though.
- dnautics 13y agoI'm biased, back in the BeOS -> Haiku days, I was wanting some sort of configuration textfile that would neatly be able to be parsed into a BArchive object (and presumably transmitted into a BMessage). XML was all the rage at the time, so I wrote for myself a sort of XML-ish format, but I never contributed it to the tree. I learned the problems with XMLs (should it be an attribute or an innerText?). I wanted something with a bracket notation, but JSON had not been discovered by crockford yet, if it had been I would have gotten more involved and tried to have it be adopted.