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

From: Tim Bray <[email-masked]>
Date: Tue, 16 Jan 2024 10:11:08 -0500

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 <[email-masked]> wrote:

> Hi Pete,
>
> On 2024-01-16, at 14:46, Pete Cordell <[email-masked]> 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
> [email-masked]
> https://www.ietf.org/mailman/listinfo/json
>