Re: [Json] Proposed minimal change for duplicate names in objects

John Cowan <cowan@mercury.ccil.org> Wed, 03 July 2013 01:11 UTC

Return-Path: <cowan@ccil.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 00CD511E8111 for <json@ietfa.amsl.com>; Tue, 2 Jul 2013 18:11:36 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -3.599
X-Spam-Level:
X-Spam-Status: No, score=-3.599 tagged_above=-999 required=5 tests=[BAYES_00=-2.599, RCVD_IN_DNSWL_LOW=-1]
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 6+IBPqFHT2XX for <json@ietfa.amsl.com>; Tue, 2 Jul 2013 18:11:31 -0700 (PDT)
Received: from earth.ccil.org (earth.ccil.org [192.190.237.11]) by ietfa.amsl.com (Postfix) with ESMTP id A835611E810F for <json@ietf.org>; Tue, 2 Jul 2013 18:11:30 -0700 (PDT)
Received: from cowan by earth.ccil.org with local (Exim 4.72) (envelope-from <cowan@ccil.org>) id 1UuBbU-0001Xc-Qk; Tue, 02 Jul 2013 21:11:28 -0400
Date: Tue, 2 Jul 2013 21:11:28 -0400
From: John Cowan <cowan@mercury.ccil.org>
To: Paul Hoffman <paul.hoffman@vpnc.org>
Message-ID: <20130703011128.GK31347@mercury.ccil.org>
References: <B86E1D4B-1DC8-4AD6-B8B3-E989599E0537@vpnc.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <B86E1D4B-1DC8-4AD6-B8B3-E989599E0537@vpnc.org>
User-Agent: Mutt/1.5.20 (2009-06-14)
Sender: John Cowan <cowan@ccil.org>
Cc: "json@ietf.org WG" <json@ietf.org>
Subject: Re: [Json] Proposed minimal change for duplicate names in objects
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, 03 Jul 2013 01:11:36 -0000

Paul Hoffman scripsit:

> Proposal 1:
> 
> In section 2.2 (Grammar -> Objects):
>   No change
> In section 4 (Parsers):
>   Add: "If a parser encounters an object with duplicate names, the parser MUST use only the last
>   name/value pair that has the duplicate name.

I object to this, because it is unclear what "use" means.  If it means
"report to the application", then a streaming parser cannot do this
without ceasing to be streaming: that is, it must buffer up the whole
object in order to be sure not to report any inappropriate pairs.
If "use" means something else, it must be explained more clearly.

> In section 5 (Generators):
>   Add: "The names within an object SHOULD be unique."

I approve of this.  However, an additional sentence is required to explain
which names are distinct and which are not.

> Proposal 2:
> 
> Same as Proposal 1 *except* that a second sentence is added for section 4: "A parser that streams
>   its outputs MUST fail to finish parsing if it encounters more than one name/value pair with the
>   same name."

This puts only a slightly lower burden on streaming parsers: they now
do not need to buffer up the whole object, but may report it on the fly,
keeping track of the names already seen in order to fail if one of them
is a duplicate.  I still think this burden is excessive.

I therefore propose that nothing be said about parsers, but that generators
SHOULD NOT generate duplicate names, where "duplicate" is defined to mean
consisting of the same code points or scalar values, as the case may be,
in the same order.

-- 
John Cowan   cowan@ccil.org  http://www.ccil.org/~cowan
Most languages are dramatically underdescribed, and at least one is
dramatically overdescribed.  Still other languages are simultaneously
overdescribed and underdescribed.  Welsh pertains to the third category.
        --Alan King