4 ms·
> 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
by 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