[Json] Call for real-world examples of how parsers deal with duplicate keys

Paul Hoffman <paul.hoffman@vpnc.org> Thu, 06 June 2013 17:41 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 A97A021F9A1A for <json@ietfa.amsl.com>; Thu, 6 Jun 2013 10:41:24 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -102.155
X-Spam-Level:
X-Spam-Status: No, score=-102.155 tagged_above=-999 required=5 tests=[AWL=0.444, BAYES_00=-2.599, 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 69s-NfHypiD7 for <json@ietfa.amsl.com>; Thu, 6 Jun 2013 10:41:24 -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 2787421F8EC3 for <json@ietf.org>; Thu, 6 Jun 2013 10:41:19 -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 r56HfH71034581 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO) for <json@ietf.org>; Thu, 6 Jun 2013 10:41:17 -0700 (MST) (envelope-from paul.hoffman@vpnc.org)
From: Paul Hoffman <paul.hoffman@vpnc.org>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Message-Id: <C79C116D-16A4-41BA-9E5A-1055E6B9C941@vpnc.org>
Date: Thu, 06 Jun 2013 10:41:16 -0700
To: "json@ietf.org" <json@ietf.org>
Mime-Version: 1.0 (Mac OS X Mail 6.5 \(1508\))
X-Mailer: Apple Mail (2.1508)
Subject: [Json] Call for real-world examples of how parsers deal with duplicate keys
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 17:41:24 -0000

Greetings again. Knowing what current parsers do with duplicate keys might be useful to this discussion. Of course, some people will exclaim "but that's wrong!" to some of what we see, but seeing it may be useful nonetheless.

I propose the following JSON text for the tests:

{"a":1,"a":2}

--Paul Hoffman

==============================

And I'll start with Python.

from __future__ import print_function
import json
a = '{"a":1,"a":2}'
print(json.loads(a))

# python2.6 keytest.py
{u'a': 2}
# python2.7 keytest.py
{u'a': 2}
# python3.2 keytest.py
{'a': 2}