4 ms·
Not just trailing commas, but the need for commas at all when there is a newline right next to it has been a source of many stupid issues for me when less knowl
by furgooswft13 8y ago
Not just trailing commas, but the need for commas at all when there is a newline right next to it has been a source of many stupid issues for me when less knowledgeable/experienced people edit json based conf files.
Then there is floats without a leading zero. Missing colon after the key. And yea, naked keys. The need to wrap the entire file in { } or [ ] is just icing.
Honestly I feel the most bare simple conf format of [first-word] [rest-of-line] is enough for many programs that end up using but never taking advantage of more powerful formats.
- GordonS 8y ago> but the need for commas at all when there is a newline right next to it JSON is often minified though - you're going to need something to use as a delimiter
- jampekka 8y agoA newline character is just as minimal as any other ASCII delimiter.
- furgooswft13 8y agoI would hope minified JSON is not being used for conf files.
- wolfgang42 8y agoNewline and comma are both 1 byte. You could specify that either is acceptable. Actually, I think you could leave out the delimiter altogether and still be syntactically unambiguous, since quotes are required around keys: "key1":"value1""key2":2.75"key3":true"key4":"whatever" though this looks terrible and there's probably some edge case I've forgotten. (Also it misses the point of JSON in that it's no longer valid JS. I don't know whether that's important anymore since you should be calling JSON.parse() not eval() anyway.)
- furgooswft13 8y ago> you should be calling JSON.parse() not eval() The one major reason I could see to use "JSON" as a conf file is in trusted node.js apps because you can then easily embed functions and logic in them if you need more advanced/customizable configurations. And you can do it with full syntax highlighting in your editor. And comments, and trailing commas, and naked keys. Of course this is no longer JSON, it's straight up Javascript config files. But it has come in handy a few times when I want to override standard behavior on a per config basis, and most of the file is still just plain key: val