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

Paul Hoffman <paul.hoffman@vpnc.org> Thu, 06 June 2013 15:24 UTC

Return-Path: <paul.hoffman@vpnc.org>
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 E00F721F9931 for <json@ietfa.amsl.com>; Thu, 6 Jun 2013 08:24:15 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -101.166
X-Spam-Level:
X-Spam-Status: No, score=-101.166 tagged_above=-999 required=5 tests=[AWL=0.833, BAYES_00=-2.599, J_CHICKENPOX_35=0.6, USER_IN_WHITELIST=-100]
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 whzD2nWDY8Fc for <json@ietfa.amsl.com>; Thu, 6 Jun 2013 08:24:15 -0700 (PDT)
Received: from hoffman.proper.com (IPv6.Hoffman.Proper.COM [IPv6:2605:8e00:100:41::81]) by ietfa.amsl.com (Postfix) with ESMTP id 784BC21F9928 for <json@ietf.org>; Thu, 6 Jun 2013 08:24:15 -0700 (PDT)
Received: from [10.20.30.90] (50-0-66-165.dsl.dynamic.sonic.net [50.0.66.165]) (authenticated bits=0) by hoffman.proper.com (8.14.5/8.14.5) with ESMTP id r56FOEg6029624 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO) for <json@ietf.org>; Thu, 6 Jun 2013 08:24:15 -0700 (MST) (envelope-from paul.hoffman@vpnc.org)
Content-Type: text/plain; charset="us-ascii"
Mime-Version: 1.0 (Mac OS X Mail 6.5 \(1508\))
From: Paul Hoffman <paul.hoffman@vpnc.org>
In-Reply-To: <51AFC924.2030805@crockford.com>
Date: Thu, 06 Jun 2013 08:24:14 -0700
Content-Transfer-Encoding: quoted-printable
Message-Id: <DA7A83A2-1C1F-4E74-BF6A-DA943B07AB59@vpnc.org>
References: <51AF8479.5080002@crockford.com> <51AF9ACF.5020507@cisco.com> <D0A99569-0915-4862-A7AE-9DE51C2E90C0@yahoo.com> <51AFB3F8.8060708@crockford.com> <8F32953C-C788-4DC9-888E-920E2BEB7FDD@yahoo.com> <831B8E46-F239-4353-8F95-8DF3F9BD2E78@yahoo.com> <51AFC924.2030805@crockford.com>
To: "json@ietf.org" <json@ietf.org>
X-Mailer: Apple Mail (2.1508)
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: Thu, 06 Jun 2013 15:24:16 -0000

On Jun 5, 2013, at 4:26 PM, Douglas Crockford <douglas@crockford.com> wrote:

> If duplicate names are encountered, the parse MAY fail (because some implementations correctly do that), or it MAY succeed by accepting the last duplicated key:value pair.

The new text should use language that is already in RFC 4627; "key" is not such a word. To be fair to implementers, the new document also needs to deal with both emitters and parsers.

Proposal:

In Section 2.2:
Current:
   The names within an object SHOULD be unique.
Proposed:
   If the names within an object are not unique, the result of parsing the 
   object is unpredictable, and the parse may even fail completely. Thus,
   the names within an object SHOULD be unique.

In Section 4, add a new paragraph:
   If a parser encounters an object with duplicate names, the parser MAY
   fail to parse the JSON text; if the parser accepts objects with duplicate
   names, it SHOULD accept only the last name/value pair that has the
   duplicate name. 

--Paul Hoffman