Re: [Json] The names within an object SHOULD be unique.

Stefan Drees <stefan@drees.name> Mon, 10 June 2013 17:52 UTC

Return-Path: <stefan@drees.name>
X-Original-To: json@ietfa.amsl.com
Delivered-To: json@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 622A521F8749 for <json@ietfa.amsl.com>; Mon, 10 Jun 2013 10:52:12 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.092
X-Spam-Level:
X-Spam-Status: No, score=-2.092 tagged_above=-999 required=5 tests=[AWL=0.157, BAYES_00=-2.599, HELO_EQ_DE=0.35]
Received: from mail.ietf.org ([12.22.58.30]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id c3BMPEMO-RZC for <json@ietfa.amsl.com>; Mon, 10 Jun 2013 10:52:06 -0700 (PDT)
Received: from mout.web.de (mout.web.de [212.227.17.12]) by ietfa.amsl.com (Postfix) with ESMTP id 29C0B21F9953 for <json@ietf.org>; Mon, 10 Jun 2013 10:52:03 -0700 (PDT)
Received: from newyork.local.box ([93.129.126.10]) by smtp.web.de (mrweb103) with ESMTPSA (Nemesis) id 0MBTIY-1Ubgeg2llO-00A7fS; Mon, 10 Jun 2013 19:51:57 +0200
Message-ID: <51B6123B.5010708@drees.name>
Date: Mon, 10 Jun 2013 19:51:55 +0200
From: Stefan Drees <stefan@drees.name>
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130509 Thunderbird/17.0.6
MIME-Version: 1.0
To: Stephen Dolan <stephen.dolan@cl.cam.ac.uk>
References: <51AF8479.5080002@crockford.com> <CAK3OfOgtYoPRZ-Gj5G8AnNipDyxYs=6_KD=rQTxKbhDPX6FZNA@mail.gmail.com> <51b1168c.e686440a.5339.5fc4SMTPIN_ADDED_BROKEN@mx.google.com> <CAK3OfOhL3zXHfg9EEDWLXhjLQ1aBvvxikKAiR+nUpDHJaVh+Qg@mail.gmail.com> <51B1B47C.9060009@drees.name> <C86A9758-5BEF-415C-BD17-DC5E757FAA7E@yahoo.com> <51B1E909.2010402@drees.name> <CA+mHimN9=VZu4RRWcnk2F_uMi-+E-LDN2stb1MFNDP+o1R0WSg@mail.gmail.com> <51B1FE6A.80409@drees.name> <CA+mHimNuDwTF96v0PnEvFusCw-KEFT6QF4R9UeZ+8nbETB7oBw@mail.gmail.com> <51B45FAA.4070900@drees.name> <CA+mHimOBfb1RZhp6rYpL83rnHhrjNTeTeomi4hAv9avsYROE5A@mail.gmail.com> <62F282B7-11AA-44F8-A03B-201F2DAE51B5@vpnc.org> <CA+mHimNh26EUy4OxV1oSLNKvuz3VAsJjdte5ZFriTMc5HU9dRA@mail.gmail.com>
In-Reply-To: <CA+mHimNh26EUy4OxV1oSLNKvuz3VAsJjdte5ZFriTMc5HU9dRA@mail.gmail.com>
Content-Type: text/plain; charset="ISO-8859-1"; format="flowed"
Content-Transfer-Encoding: 7bit
X-Provags-ID: V02:K0:mfnvqEm2MxGgvA0MPopVecnJDrMDY2zPHkomfnZhGPn wwWWEzL8Inv8I+OednMuk6OI5QFSfQ95CSyVXsMSP+74m7e4d0 PTiNIiSIKiCNuhtdyn4vLYfGrMzqqXGSHXXpkVxwTakYxLJtMy Av/nC6igHkIAZe8WYndgs02oMYJDEPlPv2Ncmfif/kh7Gz1iYT UgJFK1ntE4/YXOGzfluDA==
Cc: Paul Hoffman <paul.hoffman@vpnc.org>, "json@ietf.org" <json@ietf.org>
Subject: Re: [Json] The names within an object SHOULD be unique.
X-BeenThere: json@ietf.org
X-Mailman-Version: 2.1.12
Precedence: list
Reply-To: stefan@drees.name
List-Id: "JavaScript Object Notation \(JSON\) WG mailing list" <json.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/json>, <mailto:json-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/json>
List-Post: <mailto:json@ietf.org>
List-Help: <mailto:json-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/json>, <mailto:json-request@ietf.org?subject=subscribe>
X-List-Received-Date: Mon, 10 Jun 2013 17:52:12 -0000

On 2013-06-10 19:08 CEST, Stephen Dolan wrote:
> On Mon, Jun 10, 2013 at 6:01 PM, Paul Hoffman ... wrote:
>> <no hat>
>>
>> On Jun 10, 2013, at 9:55 AM, Stephen Dolan ... wrote:
>>
>>> The issue is, that currently there exists a JSON document which one
>>> RFC-conforming correct JSON parser can say is indistinguishable from
>>> {a: true}, and another equally RFC-conforming correct JSON parser can
>>> say is indistinguishable from {a: false}.
>>>
>>> While my example might not have been great, this still seems easily
>>> exploitable: two parsers parsing a supposedly standard format can be
>>> tricked into seeing completely different results from the same input.
>>> Surely it would be better if we could say that one of those parsers
>>> was not RFC-conforming?
>>
>> Stated that narrowly, yes. But given your first paragraph, the comparison might be
>> more fully stated as "would it be better if we could says that one of these parsers was
>> not RFC-conforming if making such a statement caused what was a stored valid
>> JSON text now non-valid".
>
> I don't propose making any stored valid JSON text become non-valid.
> {a: true, a: false} is currently a valid JSON text, and it should
> remain so or things would break.
>
> Some JSON parsers consider that document distinguishable from {a:
> false} (e.g. streaming parsers that return all key/value pairs). Most
> of them don't.
>
> I propose that it be invalid to consider that document
> indistinguishable from {a: true}. Parsers are free to accept or reject
> it, and if they accept it they are free to return either one or two
> "a" entries, but if they only return one it must be {a: false}. ...

I presume, that if round-tripping - that is taking the "JSONing" as 
reversible operation for whatever is deemed important to keep intact 
over multiple encode-decode cycles - would have been a concern, this 
somehow would have been noted in the JSON RFC right from the start ;-)

In the current discussions I see a lot of focus on the transformation 
from JSON text into some storage structure of another representation 
motivated by consequences thereof.

If I take eg. a conforming JSON parser that keeps even the duplicated 
entries inside a map in the parsers implementation "private 
representation" and than let it act - say as a proxy - and generate 
"matching" JSON text from that again, it is perfectly valid and ok to 
receive:

     {a: true, a: false}

parse this (i.e. store) and emit as (re-)generated JSON text (forward):

     {a: false, a: true}

Right :-?)


There is some traditional asymmetry of "interest" comparing:

A) Private Storage Representation of Generator

and

B) Private Storage Representation of Parser

Isn't it? It looks more like JSON text is "simply found" as the 
interchange of the JSON represented data is the emphasis not the initial 
transformation of whatever that lead to the JSON text in the first place.

So I think what generators MAY introduce as indeterminism into the 
conversion (since years), the parsers will have to deal with (wishes 
aside).
Setting all "hope" on this weak ordering assumption leading to the 
concept of a "last" entry, which breaks down in the proxy sample given 
above, might be misleading.

Please note, that I do believe, that the discussions transported through 
all these - I guess already - 300000 words exchanged back and forth in 
the endeavour to apply some cosmetics to the 2000 words RFC are of 
sufficient value for everyone participating :-)

Stefan.