3 ms·
Newline 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 syn
by wolfgang42 8y ago
Newline 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