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

"Matt Miller (mamille2)" <mamille2@cisco.com> Thu, 06 June 2013 18:05 UTC

Return-Path: <mamille2@cisco.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 6550321E80AA for <json@ietfa.amsl.com>; Thu, 6 Jun 2013 11:05:45 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -10.599
X-Spam-Level:
X-Spam-Status: No, score=-10.599 tagged_above=-999 required=5 tests=[BAYES_00=-2.599, RCVD_IN_DNSWL_HI=-8]
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 h9k4zs0YT9Z6 for <json@ietfa.amsl.com>; Thu, 6 Jun 2013 11:05:40 -0700 (PDT)
Received: from rcdn-iport-5.cisco.com (rcdn-iport-5.cisco.com [173.37.86.76]) by ietfa.amsl.com (Postfix) with ESMTP id E17A021E80B3 for <json@ietf.org>; Thu, 6 Jun 2013 11:05:39 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=7328; q=dns/txt; s=iport; t=1370541940; x=1371751540; h=from:to:cc:subject:date:message-id:references: in-reply-to:mime-version; bh=X2GfgQEfPw7oqfWHsfwI/N2q6RpJCUajdsm9WOfZLjM=; b=elxsmNpikp0Qwrah0u5RNCXhBMC4E+L6ZRsINMHs/kfIJgZIfSwK8Dhn N4RpHxBl3F27wWaJTEQ+JeaL3cL3eW/PMbve4DyGDlx2pPrvffFnFjkUp YHzj2Jp69dQtdPy+ZMbWo97LRuN5UBPIK1zm5SpcTraAjmVGEioTwlf2G s=;
X-Files: smime.p7s : 4136
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: AgkFAE7OsFGtJXG8/2dsb2JhbABZgwkwv0d5FnSCIwEBAQMBHVwFCwIBCCIkAjAlAgQOBQgGh3kGvAOPATEHCYJxYQOQAIEshzyQF4MPgic
X-IronPort-AV: E=Sophos; i="4.87,816,1363132800"; d="p7s'?scan'208"; a="219706277"
Received: from rcdn-core2-1.cisco.com ([173.37.113.188]) by rcdn-iport-5.cisco.com with ESMTP; 06 Jun 2013 18:05:39 +0000
Received: from xhc-rcd-x05.cisco.com (xhc-rcd-x05.cisco.com [173.37.183.79]) by rcdn-core2-1.cisco.com (8.14.5/8.14.5) with ESMTP id r56I5bjh009456 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=FAIL); Thu, 6 Jun 2013 18:05:37 GMT
Received: from xmb-aln-x11.cisco.com ([169.254.6.24]) by xhc-rcd-x05.cisco.com ([173.37.183.79]) with mapi id 14.02.0318.004; Thu, 6 Jun 2013 13:05:37 -0500
From: "Matt Miller (mamille2)" <mamille2@cisco.com>
To: Paul Hoffman <paul.hoffman@vpnc.org>
Thread-Topic: [Json] Call for real-world examples of how parsers deal with duplicate keys
Thread-Index: AQHOYt0SaR52gsJ1Vkq+L7gyeb9HuZkpTvoA
Date: Thu, 06 Jun 2013 18:05:36 +0000
Message-ID: <BF7E36B9C495A6468E8EC573603ED9411527E77E@xmb-aln-x11.cisco.com>
References: <C79C116D-16A4-41BA-9E5A-1055E6B9C941@vpnc.org>
In-Reply-To: <C79C116D-16A4-41BA-9E5A-1055E6B9C941@vpnc.org>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach: yes
X-MS-TNEF-Correlator:
x-originating-ip: [10.129.24.59]
Content-Type: multipart/signed; boundary="Apple-Mail=_B9DE1BBF-213B-4F17-8444-9C106EF5AC6A"; protocol="application/pkcs7-signature"; micalg="sha1"
MIME-Version: 1.0
Cc: "json@ietf.org" <json@ietf.org>
Subject: Re: [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 18:05:45 -0000

On Jun 6, 2013, at 11:41 AM, Paul Hoffman <paul.hoffman@vpnc.org>
 wrote:

> 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}



Experiments should always have a control!  I think we can consider this the control:

-----BEGIN JAVASCRIPT-----
var input = '{"a":1,"a":2}';

var output;
output = JSON.parse(input);
output = JSON.stringify(output);

console.log(output);
-----END JAVASCRIPT-----

# node.js 0.10.8
{"a":2}

# Firefox 22
{"a":2}

# Safari 6.5
{"a":2}

# Chrome 27
{"a":2}


- m&m

Matt Miller < mamille2@cisco.com >
Cisco Systems, Inc.