On 24-Jul-08, at 8:02 PM, Christopher Schmidt wrote: > On Fri, Jul 25, 2008 at 01:37:37AM +0200, Kristian Thy wrote: >> On Thu, Jul 24, Christopher Schmidt wrote: >>> On Thu, Jul 24, 2008 at 06:07:02PM -0500, Erik Uzureau wrote: >>>> it was explained to me at some point in life that the "proper" JSON >>>> notation was >>>> putting quotes (single?) around the key names, ie: >>> >>> "Double", but I never let that affect my Javascript. >> >> Single and double quotes are interchangeable (as long as they match >> in >> pairs :-) ) in Javascript, just as in (X)HTML. > > JSON is not Javascript. > > JSON is a subset of Javascript, and single quotes are not allowed. > > (As far as I know, all Javascript JSON parsers support single-quoted > keys/values, but most other implementations do not.)
For reference, see the language description at http://json.org/. I'm lazy and have trained myself to use single quotes to save the effort of hitting the shift key in javascript, but it does become important in other languages like PHP where double-quoted strings are different from single quoted strings. I don't really have a preference for coding objects in javascript (a minor preference to no quoting of keys in objects), but if we are preparing a JSON string for consumption elsewhere then it should follow the spec and not rely on javascript's flexibility. Cheers Paul __________________________________________ Paul Spencer Chief Technology Officer DM Solutions Group Inc http://www.dmsolutions.ca/ _______________________________________________ Users mailing list [email protected] http://openlayers.org/mailman/listinfo/users
