Sorry, why exactly can’t they also define the json.parse/stringify behavior of bigints? JSON was initially derived from JavaScript, so it seems a bit weird that a new ES standard can’t interoperate with json
Sorry, why exactly can’t they also define the json.parse/stringify behavior of bigints? JSON was initially derived from JavaScript, so it seems a bit weird that a new ES standard can’t interoperate with json
Because every construct in JSON already has a defined way that it is parsed into JS and incorporating BigInt into that by default would break backwards compatibility of JS’s JSON handling.
Interop concerns make the right JSON serialization very application dependent, too.
RFC 8259, Section 6, specifies unlimited number of digits for the integer and fraction parts, but allows implementations to have size and precision constraints.
> I thought it was limited to javascript numbers.
It suggest that IEEE754 binary64, because it is widely available and supported, should generally be safely usable (which happens to be exactly JavaScript numbers) but it does not limit JSON numbers to that range/precision.
Arbitrarily sized numbers (with no guarantee on supported range or precision in processors) are part of the spec, the problem is JS already serializes/deserializes them as Number and any change would break backwards compatibility.