Pseudo-JSON with unquoted property names

David-Sarah Hopwood david-sarah at jacaranda.org
Thu Jun 4 16:11:41 PDT 2009


Brendan Eich wrote:
> On Jun 3, 2009, at 10:02 PM, Allen Wirfs-Brock wrote:
>>> From: es5-discuss-bounces at mozilla.org [mailto:es5-discuss-
>>>
>>>>> - unquoted property names, matching <IdentifierName>, in
>>>>>  object literals.
>>>>
>>>> Why? Had JSON been defined after ES5, no doubt it would have accepted
>>>> these. But that's spilled milk under the bridge on which the train has
>>>> already passed.
>>>
>>> This has nothing to do with ES5. It is about the fact that there is a
>>> *lot* of nonconformant pseudo-JSON out there that has unquoted property
>>> names. Rejecting it will make the ES5 JSON parser significantly less
>>> useful and less interoperable.
>>
>> The IE8 implementation of JSON.parse does not allow unquoted property
>> names. While I have seen reports regarding several issues with the IE8
>> implementation,(for example, one site that allowed use of single
>> quotes as string quotes within JSON text) I have yet to hear any
>> complaints about not allowing unquoted property names. This doesn't
>> prove that such pseudo-JSON doesn't exist but it may indicate that it
>> isn't a serious problem.
> 
> Same here, we've yet to receive such a bug report.. I can believe almost
> any claim about funny content on the web (not ha-ha funny, either), but
> it would be great to have some links to public instances of JSON data
> with unquoted property names.
> 
> David-Sarah, can you cite any?

Documentation for an emitter that produces unquoted property names (UPNs)
by default:
<http://www.uize.com/reference/uize.json.html#2_2_7>


Blog post about Ruby on Rails' JSON emitter prior to version 2.0
(released in December 2007) producing UPNs:
<http://blog.codefront.net/2007/06/20/how-to-get-strictly-valid-json-from-rails/>


These two emitters are interesting because they both have or had an
option controlling whether to produce unquoted or quoted property names,
with a deliberate decision (later reversed in the Rails case) to make
unquoted the default. So this cannot be attributed merely to implementor
laziness or carelessness, since they had to do more work in order to
support both options.

For Rails, see <http://www.ruby-forum.com/topic/124797> and
<http://dev.rubyonrails.org/changeset/6443#file5> for more evidence that
this was a deliberate design decision.


Documentation of a format claimed to be JSON but with UPNs:
<http://simile.mit.edu/wiki/Exhibit/Creating,_Importing,_and_Managing_Data>

["Property names that don't contain non-alphanumeric characters, e.g.,
  label and worksAt, don't need to be quoted..."]


Bug report about as3corelib's JSON parser needing to accept UPNs:
<http://code.google.com/p/as3corelib/issues/detail?id=35>
and with a real-world example of pseudo-JSON:
<http://code.google.com/p/as3corelib/issues/detail?id=83>
Related blog post:
<http://www.darronschall.com/weblog/2007/07/parse-errors-with-actionscript-3s-json-library.cfm>


A couple more examples of pseudo-JSON:
<http://bytes.com/groups/javascript/714878-json-object-not-parsing-firefox>
<http://dev.rubyonrails.org/ticket/10133>

-- 
David-Sarah Hopwood  ⚥  http://davidsarah.livejournal.com



More information about the es5-discuss mailing list