[squeak-dev] Re: JSON "object"s are *unordered*

Colin Putney cputney at wiresong.ca
Tue Jan 12 18:21:52 UTC 2010


On 2010-01-12, at 8:35 AM, Tony Garnock-Jones wrote:

> Igor Stasenko wrote:
>> Is there something what depends on a specific key order?
> 
> If there is, it's busted.
> 
>> From json.org: "An object is an unordered set of name/value pairs."
> 
>> From RFC 4627: "An object is an unordered collection of zero or more
> name/value pairs, where a name is a string and a value is a string,
> number, boolean, null, object, or array."
> 
> Both quotes are referring to the semantics of the represented values
> (the "infoset" if you like), rather than the transfer syntax.
> 
> My question is: what motivated the change to using a specific key
> ordering when serializing to JSON? From examining MC history, it looks
> like Colin Putney introduced the change: Colin, can you comment?
> 
> (In particular, since Dictionary>>= operates without regard for order of
> key insertion, it must have been something to do with external
> representation rather than manipulation of values from within the image.)

I think it was for testing. I had a bunch of tests in OB-Web that asserted this or that JSON object was being sent over the wire, and didn't want to get into the circularity of parsing them again to do the comparisons. Making the serialization order consistent made the tests easier. That was meant to be a private change though, not sure how it got pushed upstream. It appears to be causing havoc; sorry about that!

Colin


More information about the Squeak-dev mailing list