Re: [Json] Limitations on number size?

Tatu Saloranta <tsaloranta@gmail.com> Thu, 11 July 2013 04:10 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 AF4D221F92BB for <json@ietfa.amsl.com>; Wed, 10 Jul 2013 21:10:09 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.498
X-Spam-Level:
X-Spam-Status: No, score=-2.498 tagged_above=-999 required=5 tests=[AWL=0.101, 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 01qapWrsW3ol for <json@ietfa.amsl.com>; Wed, 10 Jul 2013 21:10:09 -0700 (PDT)
Received: from mail-we0-x22c.google.com (mail-we0-x22c.google.com [IPv6:2a00:1450:400c:c03::22c]) by ietfa.amsl.com (Postfix) with ESMTP id 3F59921F9263 for <json@ietf.org>; Wed, 10 Jul 2013 21:10:07 -0700 (PDT)
Received: by mail-we0-f172.google.com with SMTP id q56so6617373wes.3 for <json@ietf.org>; Wed, 10 Jul 2013 21:10:07 -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=1RO9W9STxQDBEn2JmmiZt3hu0o9YXlDoYfZiKBra2FU=; b=uiB/gHKUDrsr1KUhkJyT4Z6k3bDC1luVZ28wM8TuqS+/ayit2m9oxT92/bTCBLJ1/N XAJQBxQYLZNW3jnaulp5QovUJWYmepX6jO9ygIV8evgyQFCTkPG/CYT/dUr60B9R7oR/ lvSiHHtUd5ZgJu35NN54o7QpKv5fxpt9la/yznw0nE2rRRPHvGg+OxHOcJdWhytNQCT+ YpZdT+j3IQU7Hkv4FMh70tvcLs4rfHqf1NBKEXWPFjov8QvyibL95DxiZu6ejvcigl3n REzaqlaQe0m0aN+EyjlwD5XqXZDGq+9ISddeEtFldXFiNl/yMBfaM2GCF8wUy0ww1Ql7 AiGw==
MIME-Version: 1.0
X-Received: by 10.180.206.70 with SMTP id lm6mr36671963wic.50.1373515807246; Wed, 10 Jul 2013 21:10:07 -0700 (PDT)
Received: by 10.227.34.199 with HTTP; Wed, 10 Jul 2013 21:10:07 -0700 (PDT)
In-Reply-To: <CAO1wJ5RRk+GoJKUizp1Q92rRMNy62sYER-=6SUwjPh30DSuBwg@mail.gmail.com>
References: <51DC0F95.7010407@gmail.com> <hf8ot8hnpa93pi3t54c4d5qcc3p5tnb3ca@hive.bjoern.hoehrmann.de> <CAK3OfOgTNaLpRthrRcU4Bo+3z1aXUOOn0Ord7RBPN8z6TtiiWw@mail.gmail.com> <51DC7F87.6060503@gmail.com> <CAGrxA24v5L7oCGxEOwecJSLCNiLrSWSt=jFJMA0M9E8fztNLag@mail.gmail.com> <20130710024215.GO9153@mercury.ccil.org> <CAO1wJ5RRk+GoJKUizp1Q92rRMNy62sYER-=6SUwjPh30DSuBwg@mail.gmail.com>
Date: Wed, 10 Jul 2013 21:10:07 -0700
Message-ID: <CAGrxA26fskGojrw1dbpFFRcpkedQkWMYiAMON2nnY8H2XLbzXg@mail.gmail.com>
From: Tatu Saloranta <tsaloranta@gmail.com>
To: Jacob Davies <jacob@well.com>
Content-Type: multipart/alternative; boundary="001a11c265bec8d04604e1349100"
Cc: "Peter F. Patel-Schneider" <pfpschneider@gmail.com>, Nico Williams <nico@cryptonector.com>, Bjoern Hoehrmann <derhoermi@gmx.net>, John Cowan <cowan@mercury.ccil.org>, "json@ietf.org" <json@ietf.org>
Subject: Re: [Json] Limitations on number size?
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, 11 Jul 2013 04:10:09 -0000

On Wed, Jul 10, 2013 at 2:32 PM, Jacob Davies <jacob@well.com> wrote:

> On Tue, Jul 9, 2013 at 7:42 PM, John Cowan <cowan@mercury.ccil.org> wrote:
> > Apparently, there are already practical problems with interchanging
> > 64-bit longs: google for [json large numbers bugs] for lots of reports.
>
> The canonical one was Twitter IDs, where they had to introduce a
> (string) field in their JSON APIs called "id_str" which is not
> guaranteed to be equal to the obsolete-but-included (number) field
> "id".
>
> > While there are apparently int32-only systems out there, it's clearly
> > understood that they are unusually restricted: such is not the case
> > for JavaScript-hosted implementations.
>
> Yes, this is why I think the specification itself should note that for
> interoperability with Javascript, the Javascript size limitations must
> be respected, even if the specification does not require that in
> itself. The number of JSON-to-Javascript implementations or uses must
> surely outnumber all other uses of JSON by several orders of magnitude
> so I'd argue that as far as "running code" goes the limitation on
>

Any data to back that up? I would not assume this -- JSON is being used a
lot for service-to-service integration, as well as by native mobile clients.
Javascript as client is certainly important, but I would not assume any
particular majority (even simple one), and certainly not an order of
magnitude.

My experience wrt problem reports differs from that of John's, in that
while feature requests have been filed to allow limitation or truncation,
these have not been highly voted or actively followed. User community also
has not brought this up as a significant issue either.
I suspect this is because it is relatively easy to work around the problem
if and when it occurs. Developers are surprisingly resourceful in solving
problems.

practical, interoperable number size is quite real and surprising to
> people trying to send data to Javascript from non-JS environments
> where larger numbers are available. (I went so far in the Java
> libraries I wrote as to encode/decode longs & Big* as strings.)
>

Mentioning limitations is reasonable, and Javascript can be used as a
common example. There is nothing wrong in outlining challenges, best
practices. But I don't like fearmongering.

Javascript's limited support for numbers is not a JSON-specific problem --
same goes for all data formats as well; for example, XML. This is why some
concerns wrt JSON seem overblown to me.

-+ Tatu +-