Re: [Json] Canonicalization

"Manger, James H" <James.H.Manger@team.telstra.com> Wed, 20 February 2013 23:20 UTC

Return-Path: <James.H.Manger@team.telstra.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 2B81321E8030 for <json@ietfa.amsl.com>; Wed, 20 Feb 2013 15:20:06 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -0.901
X-Spam-Level:
X-Spam-Status: No, score=-0.901 tagged_above=-999 required=5 tests=[AWL=0.000, BAYES_00=-2.599, HELO_EQ_AU=0.377, HOST_EQ_AU=0.327, RELAY_IS_203=0.994]
Received: from mail.ietf.org ([64.170.98.30]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5YD8OBJ4tKF1 for <json@ietfa.amsl.com>; Wed, 20 Feb 2013 15:20:05 -0800 (PST)
Received: from ipxcvo.tcif.telstra.com.au (ipxcvo.tcif.telstra.com.au [203.35.135.208]) by ietfa.amsl.com (Postfix) with ESMTP id D1FDD21F88A1 for <json@ietf.org>; Wed, 20 Feb 2013 15:20:04 -0800 (PST)
X-IronPort-AV: E=Sophos;i="4.84,705,1355058000"; d="scan'208";a="120620699"
Received: from unknown (HELO ipccvi.tcif.telstra.com.au) ([10.97.217.208]) by ipocvi.tcif.telstra.com.au with ESMTP; 21 Feb 2013 10:20:03 +1100
X-IronPort-AV: E=McAfee;i="5400,1158,6992"; a="113916120"
Received: from wsmsg3757.srv.dir.telstra.com ([172.49.40.85]) by ipccvi.tcif.telstra.com.au with ESMTP; 21 Feb 2013 10:20:03 +1100
Received: from WSMSG3153V.srv.dir.telstra.com ([172.49.40.159]) by wsmsg3757.srv.dir.telstra.com ([172.49.40.85]) with mapi; Thu, 21 Feb 2013 10:20:02 +1100
From: "Manger, James H" <James.H.Manger@team.telstra.com>
To: Francis Galiegue <fgaliegue@gmail.com>
Date: Thu, 21 Feb 2013 10:20:02 +1100
Thread-Topic: [Json] Canonicalization
Thread-Index: Ac4PvtXolAwYhFyASYa8/C83b3BN1QAACG0Q
Message-ID: <255B9BB34FB7D647A506DC292726F6E11507634CD2@WSMSG3153V.srv.dir.telstra.com>
References: <BF7E36B9C495A6468E8EC573603ED9411513E818@xmb-aln-x11.cisco.com> <A723FC6ECC552A4D8C8249D9E07425A70F897263@xmb-rcd-x10.cisco.com> <255B9BB34FB7D647A506DC292726F6E11507579808@WSMSG3153V.srv.dir.telstra.com> <255B9BB34FB7D647A506DC292726F6E11507634C37@WSMSG3153V.srv.dir.telstra.com> <CALcybBA5ED=qj-=DXMuH_2A=d3VpkRV6KM8vtu62shRxvhm+hA@mail.gmail.com>
In-Reply-To: <CALcybBA5ED=qj-=DXMuH_2A=d3VpkRV6KM8vtu62shRxvhm+hA@mail.gmail.com>
Accept-Language: en-US, en-AU
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
acceptlanguage: en-US, en-AU
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: base64
MIME-Version: 1.0
Cc: "draft-staykov-hu-json-canonical-form@tools.ietf.org" <draft-staykov-hu-json-canonical-form@tools.ietf.org>, "json@ietf.org" <json@ietf.org>
Subject: Re: [Json] Canonicalization
X-BeenThere: json@ietf.org
X-Mailman-Version: 2.1.12
Precedence: list
List-Id: "Discussion related to JavaScript Object Notation \(JSON\)." <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: Wed, 20 Feb 2013 23:20:06 -0000

> On Wed, Feb 20, 2013 at 11:58 PM, Manger, James H
> <James.H.Manger@team.telstra.com> wrote:
> > Canonicalization (c14n) may be a dirty word, and barred from the
> charter, but I hope it isn't too inappropriate to still discuss it on
> this email list.
> >
> > There is a better c14n format for numbers than I or draft-staykov-hu-
> json-canonical-form have suggested: it is the format produced by
> JSON.stringify, as defined in ECMAScript v5.1 [http://www.ecma-
> international.org/ecma-262/5.1/#sec-15.12.3]. Examples: 0, 1, -1000,
> 0.00002334, 1500000, 6.022e+23, 9.1e-28.
> >
> > In fact, c14n for JSON can (and should) be simply defined as per
> JSON.stringify, with two extra constraints: object name/value pairs are
> sorted; and \uxxxx escapes use lowercase hex digits (a-f). Done.
> Developers even have a readily available reference implementations
> simply by typing JSON.stringify(...) into the JavaScript console of
> their browser.

> Not done. By saying that it should be done as per JSON.stringify(), you
> basically preclude the use of JSON for languages which _do_ have the
> ability to represent numbers outside of IEEE 754, and that includes
> numbers as simple as 0.1.
> 
> It is not because ECMA 262 has made the braindead decision of limiting
> numbers to IEEE 754 that JSON should follow way. RFC 4627 didn't make
> that mistake and I certainly hope any IETF-related work concerning JSON
> will not make such a mistake either.

Done (almost).

The JSON.stringify format for numbers is NOT limited to 64-bit floats. It effectively says format the number without an exponent if it is in the range [1e-6, 1e21); otherwise format it with 1 digit before the decimal point. There is no limit to the number of digits, ie the precision.

--
James Manger