couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antony Blakey <>
Subject Re: Document Updates
Date Fri, 14 Nov 2008 07:01:37 GMT

On 14/11/2008, at 2:36 PM, Noah Slater wrote:

> On Fri, Nov 14, 2008 at 01:22:58PM +1030, Antony Blakey wrote:
>>> 1. Order of fields matters which means repeated fields are ok
>>> 2. Order does not matter which means repeated fields are NOT ok
>> Given that JSON is executable Javascript, 2 is the only  
>> interpretation
>> that allows for roundtrip equivalence.
> I fear this is rather a large jump to conclusion.

I'm only claiming that *roundtrip equivalence* is only possible if you  
don't allow duplicate keys, because JSON being a serialization format  
for (limited) Javascript data structures, cannot be generated with  
duplicate keys from those data structures.

Being executable, it's interpretation is defined by the Javascript  
spec. JSON is a serialization of a (limited) Javascript data  
structure. Javascript hashes don't allow for duplicate keys, nor do  
they (AFAIR) provide any ordering guarantees. I contend that the  
semantics of JSON follow from this, and as an extension I wonder if  
any JSON that isn't a serialization of some Javascript data structure  
should not be valid JSON. OTOH, the operational interpretation would  
suggest that maybe the text representation can have duplicate keys,  
but that the data structure that it represents (which is what we  
should care about) does not.

Antony Blakey
CTO, Linkuistics Pty Ltd
Ph: 0438 840 787

Some defeats are instalments to victory.
   -- Jacob Riis

View raw message