4 ms·
I'm actually a big fan of Douglas Crockford. And don't worry, my code uses semicolons. ;) I'm not sure why you lump quoting keys with semicolons, though; his r
by aseemk 14y ago
I'm actually a big fan of Douglas Crockford. And don't worry, my code uses semicolons. ;)
I'm not sure why you lump quoting keys with semicolons, though; his regular JS style guide doesn't discourage quoting object key (neither does JSLint).
- ZenPsycho 14y agothere's a reason he requires it for JSON. it's that javascript has problems when you use a javascript reserved word as a key- for instance, if you were making an RPC api, and you had a json object {do:"methodname"} the javascript eval method would throw a fit. So rather than include the full list of javascript reserved words in a spec intended to be language agnostic, he just made quoting the key a requirement, which makes things vastly simpler.
- aseemk 14y agoThis was indeed a problem in the IE6 days. Every browser today (and ES5) supports reserved keywords as unquoted object keys. There are thus no reserved keywords for object keys in ES5, and by extension, JSON5.
- ZenPsycho 14y agoNo, but there ARE a ton of JSON parsers that expect and require quoted keys now. So it is, in fact, still a requirement. And I don't know about you, you may be lucky, but I still have to make my stuff work on IE6.
- DavidAbrams 14y agoIt's too bad, though, because all the extra quotes bloat what is otherwise a nice, spare format.
- ZenPsycho 14y agoIt has exactly the opposite effect on the notation's grammar.