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

Tatu Saloranta <tsaloranta@gmail.com> Mon, 08 July 2013 23:18 UTC

Return-Path: <tsaloranta@gmail.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 41AB421F9AD1 for <json@ietfa.amsl.com>; Mon, 8 Jul 2013 16:18:11 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.599
X-Spam-Level:
X-Spam-Status: No, score=-2.599 tagged_above=-999 required=5 tests=[AWL=0.000, BAYES_00=-2.599, HTML_MESSAGE=0.001, NO_RELAYS=-0.001]
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 jVdCeBUZwmwj for <json@ietfa.amsl.com>; Mon, 8 Jul 2013 16:18:10 -0700 (PDT)
Received: from mail-wi0-x22b.google.com (mail-wi0-x22b.google.com [IPv6:2a00:1450:400c:c05::22b]) by ietfa.amsl.com (Postfix) with ESMTP id 7806A21F9546 for <json@ietf.org>; Mon, 8 Jul 2013 16:18:10 -0700 (PDT)
Received: by mail-wi0-f171.google.com with SMTP id hj3so9551128wib.16 for <json@ietf.org>; Mon, 08 Jul 2013 16:18:09 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=kBb5gmGrZdtzbuKxYIIbwBWl2s704KsrdZN5YgEvN+s=; b=PzwI7S01d+g/qTlbh/4D+Yw/ikttQKf76/7IT5eit+CGNXhgBbw1Z7Jf+2sAzqh3R0 o5Odhvpu8LUTTD71jUb1OXtPm7m+vH9bhARIstLvqdhOI+Fo+TiqddpYFQVmkcrDtKnZ 5vxTDTwA/HSZ7mKUVZ4yi4QVEvZMWp8Mev4k3mtdoggsDmGaSPRzG2HUZjFnnyj68yIf +4EtyMKFOVYKRQlxkm7kH0WROu+5Aayke1QWI2fwbrdzZk06EZy2oNXJGHdOVcUo5Tzd /iccI6nRpF2gPhoaZNXDsn7hfqAMepBUALHSKaWo7a6lys/F58JWYz7R0NbrYHTmKEos qlzw==
MIME-Version: 1.0
X-Received: by 10.180.11.146 with SMTP id q18mr11652522wib.50.1373325489457; Mon, 08 Jul 2013 16:18:09 -0700 (PDT)
Received: by 10.227.34.199 with HTTP; Mon, 8 Jul 2013 16:18:09 -0700 (PDT)
In-Reply-To: <20130707184322.GA16880@mercury.ccil.org>
References: <00cd01ce7a9f$19adeaa0$4d09bfe0$@augustcellars.com> <00d701ce7aa6$cc5fe700$651fb500$@augustcellars.com> <CAK3OfOiWrWCvNQneokyycV1Jb98M=UR-U7z0dhxUjzVdf+PwDw@mail.gmail.com> <CAHBU6itdi3B1rWv2TiOYhL1QuOVxrFKt7OTWRoG+6TgV8Bc_uw@mail.gmail.com> <CAK3OfOgOYA5fas0oomF5amjP1bR5F=0+uve7mFD4=FMoEV7sWg@mail.gmail.com> <CAGrxA24y4D62XY-YnbDvKVwNKUickcEFxv1FUhc_yqG4KP-m-w@mail.gmail.com> <CAHBU6iuWLcXv0QKR=Ow8gkzoZLmoZjqYCqXDXR8FLVb7w7M2Tw@mail.gmail.com> <CAGrxA252xregfKViPOH7ustTSwOoorrffwdbUuCrryVxmqHUNw@mail.gmail.com> <20130707180955.GA11346@mercury.ccil.org> <18CB0DCA-36FA-4900-9A56-43ECECF2A21A@tzi.org> <20130707184322.GA16880@mercury.ccil.org>
Date: Mon, 08 Jul 2013 16:18:09 -0700
Message-ID: <CAGrxA27nm5YyB3ti2imREUgGZjo1uCgWcFPo4ZEj7rjHTEgz6A@mail.gmail.com>
From: Tatu Saloranta <tsaloranta@gmail.com>
To: John Cowan <cowan@mercury.ccil.org>
Content-Type: multipart/alternative; boundary="001a11c24d16f5d27404e1084146"
Cc: Carsten Bormann <cabo@tzi.org>, "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: Mon, 08 Jul 2013 23:18:11 -0000

On Sun, Jul 7, 2013 at 11:43 AM, John Cowan <cowan@mercury.ccil.org> wrote:

> Carsten Bormann scripsit:
>
> > In many JSON designs, the receiver knows the full set of keys ahead
> > of time.  In this case, you are better off with conditionally interning
> > it (i.e., if I already have the symbol, return it, otherwise keep the
> > string around, now we know that it didn't map to a known key).
>
> I don't know any way to do that in Java, because there seems to be no
> way to ask if a string is interned except by interning it.
>

This can be done if caller has a way to indicate set of expected possible
names, which may be the case for data-binding. This also means that actual
intern()ing can be done ahead of time, and potentially decode straight from
byte sequences to intern()ed Strings. Jackson does something similar,
although it goes via general symbol table as reuse coupled with
multi-level, varying vocabularies becomes rather hairy thing to manage
(multi-level symbol tables).

Anyway... this works for subset of cases; and many users use dynamically
generated names, open-ended domain.

-+ Tatu +-