Re: [Json] JSON and int64s - any change in current best practice since I-JSON
Rob Sayre <sayrer@gmail.com> Wed, 17 January 2024 19:25 UTC
Return-Path: <sayrer@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 6D8DCC14CE33 for <json@ietfa.amsl.com>; Wed, 17 Jan 2024 11:25:30 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.104
X-Spam-Level:
X-Spam-Status: No, score=-2.104 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, URIBL_BLOCKED=0.001, URIBL_DBL_BLOCKED_OPENDNS=0.001, URIBL_ZEN_BLOCKED_OPENDNS=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com
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 WtvlteFBzRgf for <json@ietfa.amsl.com>; Wed, 17 Jan 2024 11:25:26 -0800 (PST)
Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 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 7FDEAC14F6F0 for <json@ietf.org>; Wed, 17 Jan 2024 11:25:26 -0800 (PST)
Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-a293f2280c7so1328613266b.1 for <json@ietf.org>; Wed, 17 Jan 2024 11:25:26 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705519524; x=1706124324; darn=ietf.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=5tyG3DXgxclsigVAj8IwROXS0qQnlTY0D2XLMtEwVs4=; b=gJxfDzuK9glV+iWxQgcHO31j/EhIaPCMbW6BCm0VLBJJftdAHezgQDnILCcQcDcrFS PRXsn2EZCgGBY/LvQMZEdFnNOLt4arNM7LFuzJfYNS8jq50MkD9T/XiFSCPBPEv8z3Dw gPERacPMMhsGwFysgCuNBaVSzDzsJMNdR8AVULCE2k4nyW0qxYmHKPTdvcxQ6Au4EY9Y JFGt+VHHlzQMBqk8OHx9QFDyppzwUJyAy1wM8eoJx5w1CkuAu2v/aHRWfJn03hTVxxrt 24xah7OWS0Vrr7OsGltixL1TnL/ufHu1KXmz/ei26+3myNzLtl6XHS2eYpVs73e4Zixc gkIQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705519524; x=1706124324; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=5tyG3DXgxclsigVAj8IwROXS0qQnlTY0D2XLMtEwVs4=; b=ZQmEv8ywYg1IrRXGrHeftz62ghQXPXQFEnJztTW2DIeDegwLZeTPPnwkRva/0Zxfeh qoBmvhoNKt6M+FUqO1sJhHPXxwEzgotxqYE5ShuOb5vF7v1z5jIaqNwCsYcKNdijjzbl ailMuyCSkROfgclBR9AetTrbOobfBPoc0YdX+0Qmhd3xXGR+S8JLDotMY/K972pe7vwX RXMtrcwLHe/iRL4A8LRK/uBpU0M0kgsYtRdDTTdKEWroEePJD+3yUQrfXXMl1bxHxOIS n/i3hZeeYVuIY44T39KCnsaH0K5Rx92igRa9lg+Cng2T/qMgX+JgyGmezGWOOjA1xReA wQsA==
X-Gm-Message-State: AOJu0Ywxu+Hp9fnr9QTNbxwXCANLmHktSkEnG7tqFHOwT4Tfcy2SZICt kEJBM0VHhiGCtFJiXG26KKNAJE6bxBfuyZZRtW0=
X-Google-Smtp-Source: AGHT+IH3IDXkdIcWQEmHe4jj+YJr4QDzltOtFfotRklNde6gFLY0mhALwOoOSNpXejkRnTL1E6YSvEcdVSS3vAl3320=
X-Received: by 2002:a17:907:31c6:b0:a29:1419:f522 with SMTP id xf6-20020a17090731c600b00a291419f522mr3102837ejb.72.1705519524140; Wed, 17 Jan 2024 11:25:24 -0800 (PST)
MIME-Version: 1.0
References: <87527a42-aaac-4f39-b320-05f18a2808c1@codalogic.com> <C31BF4C8-9E6C-48F8-BF7B-D2C379273B3F@tzi.org> <CAHBU6it4SaLawSiBgK9ySkbxjtHE6CX-P3r=hzcVy4ksoQo-Cg@mail.gmail.com> <CAChr6SxHfLW-A1asAndKJz-AiyJv5QP18bi=_bNdKXw7zYHThw@mail.gmail.com> <CALH+fvrZRY2QBs7qdJj28uBC=5iVNW0=Fr0++qT-6YzXjEzvyA@mail.gmail.com>
In-Reply-To: <CALH+fvrZRY2QBs7qdJj28uBC=5iVNW0=Fr0++qT-6YzXjEzvyA@mail.gmail.com>
From: Rob Sayre <sayrer@gmail.com>
Date: Wed, 17 Jan 2024 11:25:12 -0800
Message-ID: <CAChr6SxiGAk1gmoFwRTgdzz=Qop0U7EDU+tda-ihEY0ujrFCKg@mail.gmail.com>
To: Richard Gibson <richard.gibson@gmail.com>
Cc: Tim Bray <tbray@textuality.com>, Carsten Bormann <cabo@tzi.org>, "json@ietf.org" <json@ietf.org>, Pete Cordell <petejson@codalogic.com>
Content-Type: multipart/alternative; boundary="00000000000064de7b060f29353a"
Archived-At: <https://mailarchive.ietf.org/arch/msg/json/2yYkUGLZsHURENTwaRRbelXqcUI>
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: Wed, 17 Jan 2024 19:25:30 -0000
Hi, Yes, I've seen this one. It's difficult to object to it. What is one to say? "no... you can't have access to the source text". But I don't think it will really fix this problem outside of implementations that already have a work-around in strings. thanks, Rob On Wed, Jan 17, 2024 at 11:07 AM Richard Gibson <richard.gibson@gmail.com> wrote: > When it advances sometime this year, > https://github.com/tc39/proposal-json-parse-with-source will address the > inability to represent and interact with integers outside of the IEEE 754 > binary range in browsers and other ECMAScript implementations. > > On Tue, Jan 16, 2024 at 12:10 PM Rob Sayre <sayrer@gmail.com> wrote: > >> Hi, >> >> I had the same thought as Pete a while back, but found that JS engines >> actually bar you from encoding these as JSON: >> >> > let two_55th = BigInt(2) ** BigInt(55) >> > two_55th >> 36028797018963968n >> > JSON.stringify(two_55th) >> VM189:1 Uncaught TypeError: Do not know how to serialize a BigInt >> at JSON.stringify (<anonymous>) >> at <anonymous>:1:6 >> >> I can't find the reference for this one, but the reason they gave was >> that /adding/ support broke too much running code, even though it would be >> easy to add, since the second command there sure does stringify that number. >> >> I think the issue was that too many programs rely on JSON.parse returning >> a JavaScript Number type (distinct from BigInt), so you'll run into >> problems like this TypeError: >> >> > let my_plain_number = JSON.parse("42") >> > my_plain_number >> 42 >> > my_plain_number + two_55th >> VM429:1 Uncaught TypeError: Cannot mix BigInt and other types, use >> explicit conversions >> at <anonymous>:1:17 >> >> So, I-JSON remains correct. >> >> thanks, >> Rob >> >> >> On Tue, Jan 16, 2024 at 7:11 AM Tim Bray <tbray@textuality.com> wrote: >> >>> Carsten is right. You probably wouldn’t use JSON if you weren’t likely >>> to be interchanging it with other parties over the network, other parties >>> you don’t control. For quite a while, it has been quite likely that the >>> other parties use JavaScript, and the limits I-JSON places on numbers are a >>> result of this fact. This fact isn’t going away AFAIK. >>> >>> On Jan 16, 2024 at 6:22:31 AM, Carsten Bormann <cabo@tzi.org> wrote: >>> >>>> 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 >>>> >>>> _______________________________________________ >>>> json mailing list >>>> json@ietf.org >>>> https://www.ietf.org/mailman/listinfo/json >>>> >>> _______________________________________________ >>> json mailing list >>> json@ietf.org >>> https://www.ietf.org/mailman/listinfo/json >>> >> _______________________________________________ >> json mailing list >> json@ietf.org >> https://www.ietf.org/mailman/listinfo/json >> >
- [Json] JSON and int64s - any change in current be… Pete Cordell
- Re: [Json] JSON and int64s - any change in curren… Carsten Bormann
- Re: [Json] JSON and int64s - any change in curren… Tim Bray
- Re: [Json] JSON and int64s - any change in curren… Rob Sayre
- Re: [Json] JSON and int64s - any change in curren… Rob Sayre
- Re: [Json] JSON and int64s - any change in curren… Joe Hildebrand
- Re: [Json] JSON and int64s - any change in curren… Tim Bray
- Re: [Json] JSON and int64s - any change in curren… Carsten Bormann
- Re: [Json] JSON and int64s - any change in curren… Pete Cordell
- Re: [Json] JSON and int64s - any change in curren… Pete Cordell
- Re: [Json] JSON and int64s - any change in curren… Joe Hildebrand
- Re: [Json] JSON and int64s - any change in curren… Carsten Bormann
- Re: [Json] JSON and int64s - any change in curren… Joe Hildebrand
- Re: [Json] JSON and int64s - any change in curren… Carsten Bormann
- Re: [Json] JSON and int64s - any change in curren… Tim Bray
- Re: [Json] JSON and int64s - any change in curren… Carsten Bormann
- Re: [Json] JSON and int64s - any change in curren… Joe Hildebrand
- Re: [Json] JSON and int64s - any change in curren… Carsten Bormann
- Re: [Json] JSON and int64s - any change in curren… Joe Hildebrand
- Re: [Json] JSON and int64s - any change in curren… Anders Rundgren
- Re: [Json] JSON and int64s - any change in curren… Rob Sayre
- Re: [Json] JSON and int64s - any change in curren… Rob Sayre
- Re: [Json] JSON and int64s - any change in curren… Tim Bray
- Re: [Json] JSON and int64s - any change in curren… Joe Hildebrand
- Re: [Json] JSON and int64s - any change in curren… Rob Sayre
- Re: [Json] JSON and int64s - any change in curren… Carsten Bormann
- Re: [Json] JSON and int64s - any change in curren… Rob Sayre
- Re: [Json] JSON and int64s - any change in curren… Joe Hildebrand
- Re: [Json] JSON and int64s - any change in curren… Carsten Bormann
- Re: [Json] JSON and int64s - any change in curren… Joe Hildebrand
- Re: [Json] JSON and int64s - any change in curren… Carsten Bormann
- Re: [Json] JSON and int64s - any change in curren… Rob Sayre
- Re: [Json] JSON and int64s - any change in curren… Joe Hildebrand
- Re: [Json] JSON and int64s - any change in curren… Joe Hildebrand
- Re: [Json] JSON and int64s - any change in curren… Tim Bray
- Re: [Json] JSON and int64s - any change in curren… Daniel P
- Re: [Json] JSON and int64s - any change in curren… Carsten Bormann
- Re: [Json] JSON and int64s - any change in curren… Joe Hildebrand
- Re: [Json] JSON and int64s - any change in curren… Tim Bray
- Re: [Json] JSON and int64s - any change in curren… Rob Sayre
- Re: [Json] JSON and int64s - any change in curren… Carsten Bormann
- Re: [Json] JSON and int64s - any change in curren… Carsten Bormann
- Re: [Json] JSON and int64s - any change in curren… Joe Hildebrand
- Re: [Json] JSON and int64s - any change in curren… Joe Hildebrand
- Re: [Json] [Cbor] JSON and int64s - any change in… Carsten Bormann
- Re: [Json] JSON and int64s - any change in curren… Richard Gibson
- Re: [Json] [Cbor] JSON and int64s - any change in… Jeremy O'Donoghue
- Re: [Json] [Cbor] JSON and int64s - any change in… Carsten Bormann
- Re: [Json] [Cbor] JSON and int64s - any change in… Jeremy O'Donoghue
- Re: [Json] JSON and int64s - any change in curren… Joe Hildebrand
- Re: [Json] [Cbor] JSON and int64s - any change in… Carsten Bormann
- Re: [Json] JSON and int64s - any change in curren… Rob Sayre
- Re: [Json] [Cbor] JSON and int64s - any change in… Jeremy O'Donoghue