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

John Cowan <> Wed, 03 July 2013 16:27 UTC

Return-Path: <>
Received: from localhost (localhost []) by (Postfix) with ESMTP id 91E1111E81F3 for <>; Wed, 3 Jul 2013 09:27:36 -0700 (PDT)
X-Virus-Scanned: amavisd-new at
X-Spam-Flag: NO
X-Spam-Score: -3.556
X-Spam-Status: No, score=-3.556 tagged_above=-999 required=5 tests=[AWL=0.043, BAYES_00=-2.599, RCVD_IN_DNSWL_LOW=-1]
Received: from ([]) by localhost ( []) (amavisd-new, port 10024) with ESMTP id oj5lxcaMfEHT for <>; Wed, 3 Jul 2013 09:27:32 -0700 (PDT)
Received: from ( []) by (Postfix) with ESMTP id 138CA11E81E8 for <>; Wed, 3 Jul 2013 09:27:32 -0700 (PDT)
Received: from cowan by with local (Exim 4.72) (envelope-from <>) id 1UuPtx-0000F3-WA; Wed, 03 Jul 2013 12:27:30 -0400
Date: Wed, 3 Jul 2013 12:27:29 -0400
From: John Cowan <>
To: Nico Williams <>
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: Paul Hoffman <>, Eliot Lear <>, " 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 16:27:36 -0000

Nico Williams scripsit:

> > You've got to retain state.  You don't have to retain the value, but you
> > do have to retain the name.  It's O(k), and knowing you I know you're
> > smart enough to approach that (because I am and so I'm using inductive
> > theory ;-).  And I'll bet you a nickel that this is not going to be
> > anyone's high order bit.

I do not understand the third sentence.  If k is a constant, then O(k) is
the same as O(1), and it is palpable that you cannot pack all the names
of a JSON object into O(1) space, since the amount you need varies as the
product of the (mean) length of the names and the number of names.  As
such, it is not even O(n).  You can get an O(n) probabilistic implementation
by retaining fixed-length hashes of the names already seen, though.

> You'd only have to retain state to satisfy this up-till-now
> non-existent requirement.

Quite so.

> It's a psychological cost too.  No one wants their code rendered
> non-compliant by a new RFC.  That's part of what's making it hard to
> get consensus.

True, but we gave way to that feeling, we'd never have any new standards,
as the first thing a standard does is to break existing implementations.
("The first thing a principle does is kill somebody."  --Peter Wimsey)
We must simply take the view of the ANSI C Rationale, which wisely said
"Existing code [meaning user code, the equivalent of JSON data] is
important; existing implementations are not."

> *My* opinion here is that in the case of streaming generators and
> parsers the burden of avoiding/dealing with duplicate names should be
> one layer higher: at the applications using them.  But it's also my
> opinion that some such apps may not be able to do anything about this
> either,


> which is why my proposal is we write SHOULD and explain when
> it's OK to not stick to the SHOULD.

In that case, we should write a conditional MUST.  We use SHOULD when
we want to provide scope for implementer judgement.  But that is an
editorial detail.

John Cowan    
"After all, would you consider a man without honor wealthy, even if his
Dinar laid end to end would reach from here to the Temple of Toplat?"
"No, I wouldn't", the beggar replied.  "Why is that?" the Master asked.
"A Dinar doesn't go very far these days, Master.        --Kehlog Albran
Besides, the Temple of Toplat is across the street."      The Profit