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

John Cowan <> Wed, 03 July 2013 01:11 UTC

Return-Path: <>
Received: from localhost (localhost []) by (Postfix) with ESMTP id 00CD511E8111 for <>; Tue, 2 Jul 2013 18:11:36 -0700 (PDT)
X-Virus-Scanned: amavisd-new at
X-Spam-Flag: NO
X-Spam-Score: -3.599
X-Spam-Status: No, score=-3.599 tagged_above=-999 required=5 tests=[BAYES_00=-2.599, RCVD_IN_DNSWL_LOW=-1]
Received: from ([]) by localhost ( []) (amavisd-new, port 10024) with ESMTP id 6+IBPqFHT2XX for <>; Tue, 2 Jul 2013 18:11:31 -0700 (PDT)
Received: from ( []) by (Postfix) with ESMTP id A835611E810F for <>; Tue, 2 Jul 2013 18:11:30 -0700 (PDT)
Received: from cowan by with local (Exim 4.72) (envelope-from <>) id 1UuBbU-0001Xc-Qk; Tue, 02 Jul 2013 21:11:28 -0400
Date: Tue, 2 Jul 2013 21:11:28 -0400
From: John Cowan <>
To: Paul Hoffman <>
Message-ID: <>
References: <>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <>
User-Agent: Mutt/1.5.20 (2009-06-14)
Sender: John Cowan <>
Cc: " WG" <>
Subject: Re: [Json] Proposed minimal change for duplicate names in objects
X-Mailman-Version: 2.1.12
Precedence: list
List-Id: "JavaScript Object Notation \(JSON\) WG mailing list" <>
List-Unsubscribe: <>, <>
List-Archive: <>
List-Post: <>
List-Help: <>
List-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
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