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

Douglas Crockford <douglas@crockford.com> Wed, 05 June 2013 21:56 UTC

Return-Path: <douglas@crockford.com>
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 DA52721F8B35 for <json@ietfa.amsl.com>; Wed, 5 Jun 2013 14:56:28 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.299
X-Spam-Level:
X-Spam-Status: No, score=-2.299 tagged_above=-999 required=5 tests=[AWL=-0.300, BAYES_00=-2.599, J_CHICKENPOX_34=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 SeKVQYE64D5F for <json@ietfa.amsl.com>; Wed, 5 Jun 2013 14:56:23 -0700 (PDT)
Received: from mout.perfora.net (mout.perfora.net [74.208.4.194]) by ietfa.amsl.com (Postfix) with ESMTP id 9F7DD21F8CB5 for <json@ietf.org>; Wed, 5 Jun 2013 14:56:22 -0700 (PDT)
Received: from [192.168.114.223] ([216.113.168.135]) by mrelay.perfora.net (node=mrus3) with ESMTP (Nemesis) id 0LvVEJ-1UJ1iE0zGF-00zq9s; Wed, 05 Jun 2013 17:56:21 -0400
Message-ID: <51AFB3F8.8060708@crockford.com>
Date: Wed, 05 Jun 2013 14:56:08 -0700
From: Douglas Crockford <douglas@crockford.com>
User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:17.0) Gecko/20130509 Thunderbird/17.0.6
MIME-Version: 1.0
To: Vinny A <jsontest@yahoo.com>
References: <51AF8479.5080002@crockford.com> <51AF9ACF.5020507@cisco.com> <D0A99569-0915-4862-A7AE-9DE51C2E90C0@yahoo.com>
In-Reply-To: <D0A99569-0915-4862-A7AE-9DE51C2E90C0@yahoo.com>
Content-Type: text/plain; charset="UTF-8"; format="flowed"
Content-Transfer-Encoding: 7bit
X-Provags-ID: V02:K0:DGn+WcFvzwVBBUFZsMOnNxVuBuwN5MANBqqjPoheHMr aSYMK3UF0MsUXewtjvx536smcOyeTbWiQULF3K3QSHYZN/7Ehr PzGbyteJs2b2DrsHOPGezxQDgLMkzN5QXsbK7qazfsRkJ3fc3H qX1S53xf+E98pfybAK8rlCkC0QgDd7j0+Xnj76crBCrDhZ5ajd izNnjSc3vWLMPXgcsz2v8HPFK5x4jGd8a+j2bPvHK/Kfe6vuy5 WKICdnUfiy/LzoJKfqVmwLlPwzk/hKFaszutnIRD2HHFWPrDsM LtxQs3h8PI9I38JdFi1gawWKn41gHREqAQfjAQH0wlDP8y8uHC RAogGQCP5ZEiVRqt0KjMjA5aaYtQ+Wzjex8TJUryc
Cc: Eliot Lear <lear@cisco.com>, "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
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: Wed, 05 Jun 2013 21:56:29 -0000

On 6/5/2013 1:59 PM, Vinny A wrote:
>
> On Jun 5, 2013, at 2:30 PM, Stephan Beal <sgbeal@googlemail.com 
> <mailto:sgbeal@googlemail.com>> wrote:
>> It gives implementations leeway on what is essentially a corner case 
>> (who actively generates non-unique keys?). Forcing a specific 
>> behaviour here could potentially leave a lot of current 100% 
>> JSON-compliant parsers suddenly non-compliant because of [what i 
>> perceive as] an unusual corner case.
>
> If parsers are accepting duplicate keys, they're already 
> non-compliant. RFC 4627 states that keys should be unique, and the 
> org.json reference parser throws an exception when it hits a duplicate 
> key (line 1186 in JSONObject).
>
> If any implementation is relying on using duplicate keys, they should 
> also understand that they are already violating best practice.

There are people who interpreted the SHOULD as DON'T HAVE TO and 
intentionally duplicated the keys. My personal feeling is that we should 
change the SHOULD to MUST and let those applications break. But the 
consensus of ECMA TC39 is that the SHOULD must stand.

So regrettably, that means we should be explicit about what happens when 
this particular bad practice is practiced.