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

Stefan Drees <stefan@drees.name> Fri, 07 June 2013 10:23 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 9DED521F93C4 for <json@ietfa.amsl.com>; Fri, 7 Jun 2013 03:23:08 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.93
X-Spam-Level:
X-Spam-Status: No, score=-1.93 tagged_above=-999 required=5 tests=[AWL=-0.281, BAYES_00=-2.599, HELO_EQ_DE=0.35, J_CHICKENPOX_22=0.6]
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 fGSAvTLie6LI for <json@ietfa.amsl.com>; Fri, 7 Jun 2013 03:22:58 -0700 (PDT)
Received: from mout.web.de (mout.web.de [212.227.17.11]) by ietfa.amsl.com (Postfix) with ESMTP id 3E38321F8E89 for <json@ietf.org>; Fri, 7 Jun 2013 03:22:57 -0700 (PDT)
Received: from newyork.local.box ([93.129.186.5]) by smtp.web.de (mrweb101) with ESMTPSA (Nemesis) id 0LpwB1-1U8WOR36db-00ffl6; Fri, 07 Jun 2013 12:22:53 +0200
Message-ID: <51B1B47C.9060009@drees.name>
Date: Fri, 07 Jun 2013 12:22:52 +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: Markus Lanthaler <markus.lanthaler@gmx.net>
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> <009801ce635e$0bef7080$23ce5180$@lanthaler@gmx.net>
In-Reply-To: <009801ce635e$0bef7080$23ce5180$@lanthaler@gmx.net>
Content-Type: text/plain; charset="windows-1252"; format="flowed"
Content-Transfer-Encoding: 8bit
X-Provags-ID: V03:K0:oaeNwssZ+xzM/HCHfj7mVijbElPnVh+TFciVDS3BBka2Kqb4fw7 /G/o2XmNI0IhFgu0K9+e5bKyZBIUmmjI4LTUX/dZ0aNOOuUlPIgMAAJz/rE04a57wpatLZD K5dIrArhDfYHvaQOka0rDfxID/tAJjtARJ8bEF7P2rUdJAgPXCHND+8uxntR/2IbnrM+tHX /NmArJOIdmPcO2LH/x+6A==
Cc: 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: Fri, 07 Jun 2013 10:23:09 -0000

On 2013-06-07 11:04, Markus Lanthaler wrote:
> On Friday, June 07, 2013 2:14 AM, Nico Williams wrote:
>> On Jun 6, 2013 6:09 PM, "Markus Lanthaler" <markus.lanthaler@gmx.net> wrote:
>>>
>>> On Sent: Friday, June 07, 2013 12:22 AM, Nico Williams wrote:
>>>> Having thought this far, I propose this text:
>>>>
>>>>     Encoders SHOULD NOT send duplicate keys.  Some encoders might not
>>>> be able to prevent duplicate keys.  Therefore parsers MUST be prepared
>>>> to handle duplicate keys.
>>>
>>> -1, it is very reasonable to reject such JSON.
>>
>> I wrote "handle", not "accept".
>
> If your "handle" implies that an error might be raised then it would
> be OK but I believe most people wouldn't understand it that way.

weighting the part following the "but" I read (and second) this as -1

In case TL;DR please goto "TL;DR"

Three further remarks ignited in me by the above text (that was proposed 
by Nico Williams):

"""
Encoders SHOULD NOT send duplicate keys.  Some encoders might not
be able to prevent duplicate keys.  Therefore parsers MUST be prepared
to handle duplicate keys.
"""

Which b.t.w. I would certainly rewrite as:

NEW
"""
Generators SHOULD NOT duplicate names in objects.  Parsers MUST be 
prepared to either accept duplicate names in objects or reject the 
complete JSON text containing these, as a generator might not avoid nor 
detect such duplication.
"""

"TL;DR":
Above is my proposal if we really want to change the current wording and 
if we settle on the terms generator and parser. Otherwise replace with 
encoder and decoder ;-)

Now for something completely different (the promised remarks):

A) encoders relate to parsers?

There seem to be some projections of the spec we really need to check 
periodically, so not "hypernyms" slip in ...

Let us please not cross-mix members of dimensional pairs:

* ("encoder","decoder")
* ("accept","reject")
* ("interpret","ignore")
* ("generator","parser")
* ("producer","consumer")
* ("sender","receiver")
* ("service","client")
* ...


B) We can "handle" anything :-)

The verb "handle" IMO is related to far too many possible actions:
accept, reject, interpret, ignore all jump to my mind, when I'm 
requested to handle something.

On a more higher level the robustness principle (a.k.a. Postel’s law) 
cf. [RFC1122]: "Be liberal in what you accept, and conservative in what 
you send" (*) might at first glance help advice the participants in the 
lax historically grown state we're, **but**

1. we now have all kind of JSON consumers ranging from the brittle 
("picky") to the robust ("close to blind").

2. we define a format, and not a "JSON service" or the like

As I understood, we do not change practical usage of the spec, but on 
occasion of augmenting the RFC to STD and avoiding a cyclic normative 
referencing between JSON RFC and ECMAScript spec we perform "some non 
interupting hygienic actions".

So I think there will be only microscopic changes (compared to the old 
RFC) on this topic left over after consensus calls.


C) "names" are not "keys"

Again in above text (and at the heart of the discussion IMO) we take the 
"name"s of the object members as "key" but do not say so in the RFC, and 
did not in the original.

This semantic difference and the historical fact that it was not spelled 
out in the original RFC gently directs us to just leave the "names" 
condition as is, and not start expressing our whishful thinking, we 
could simply rename these as "key" and have all the uniqueness readily 
at hand.


References:

[RFC1122]: Braden, R., Ed., "Requirements for Internet Hosts -
            Communication Layers", STD 3, RFC 1122, October 1989.
            http://www.ietf.org/rfc/rfc1122.txt.

*): I know RFC791 is historically the first similar mention, but it is 
obsoleted as RFC, so ...

All the best,
Stefan.