Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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).



there'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.


This 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.


No, 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.


It's too bad, though, because all the extra quotes bloat what is otherwise a nice, spare format.


It has exactly the opposite effect on the notation's grammar.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: