Re: [Json] JSON and int64s - any change in current best practice since I-JSON

Carsten Bormann <cabo@tzi.org> Tue, 16 January 2024 14:54 UTC

Return-Path: <cabo@tzi.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 91455C13AE21 for <json@ietfa.amsl.com>; Tue, 16 Jan 2024 06:54:07 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.909
X-Spam-Level:
X-Spam-Status: No, score=-1.909 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01] autolearn=ham autolearn_force=no
Received: from mail.ietf.org ([50.223.129.194]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yftWdf5endeo for <json@ietfa.amsl.com>; Tue, 16 Jan 2024 06:54:03 -0800 (PST)
Received: from smtp.zfn.uni-bremen.de (smtp.zfn.uni-bremen.de [IPv6:2001:638:708:32::21]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id B4A0EC4ED9BF for <json@ietf.org>; Tue, 16 Jan 2024 06:22:34 -0800 (PST)
Received: from eduroam-0298.wlan.uni-bremen.de (eduroam-0298.wlan.uni-bremen.de [134.102.17.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.zfn.uni-bremen.de (Postfix) with ESMTPSA id 4TDrnM5NZVzDCbN; Tue, 16 Jan 2024 15:22:31 +0100 (CET)
Content-Type: text/plain; charset="utf-8"
Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\))
From: Carsten Bormann <cabo@tzi.org>
In-Reply-To: <87527a42-aaac-4f39-b320-05f18a2808c1@codalogic.com>
Date: Tue, 16 Jan 2024 15:22:31 +0100
Cc: "json@ietf.org" <json@ietf.org>
X-Mao-Original-Outgoing-Id: 727107751.232173-395d96a10c3cf0a399f2dd1dc3fece66
Content-Transfer-Encoding: quoted-printable
Message-Id: <C31BF4C8-9E6C-48F8-BF7B-D2C379273B3F@tzi.org>
References: <87527a42-aaac-4f39-b320-05f18a2808c1@codalogic.com>
To: Pete Cordell <petejson@codalogic.com>
X-Mailer: Apple Mail (2.3608.120.23.2.7)
Archived-At: <https://mailarchive.ietf.org/arch/msg/json/UjfSK2VCRULP6k7_aqp4nGYo_oU>
Subject: Re: [Json] JSON and int64s - any change in current best practice since I-JSON
X-BeenThere: json@ietf.org
X-Mailman-Version: 2.1.39
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: <https://mailarchive.ietf.org/arch/browse/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: Tue, 16 Jan 2024 14:54:07 -0000

Hi Pete,

> On 2024-01-16, at 14:46, Pete Cordell <petejson@codalogic.com> wrote:
> 
> Hi All,
> 
> In I-JSON it recommends encoding 64-bit values using a string because many parsers (in particular browsers) always represent numbers using floating point doubles.

(many parsers == JavaScript’s JSON.parse)

> We're over 8 years on from I-JSON and browsers now support things like BigInt.

I’d say the problem wasn’t so much the absence of BigInt, but the fact that JavaScript’s JSON.parse always parses JSON numbers as a JavaScript Number, which is exact only inside (-2**53, 2**53).

> Therefore, I'd be interested to hear if there is any community change of opinion on how 64-bit ints should be handled in JSON.

I think we’d first need wide support for a new equivalent to JSON.parse in JavaScript.

Grüße, Carsten