Maybe have a parser function that receive the text of the number? If no
callout is specified, it could throw an appropriate error.
JSON.safeParse(json, optionalReviver, optionalParseUnrepresentable)
That would allow it to tie into future proposals like decimal, and in
conjunction with a reviver could treat an array of numbers known to be
large as an Int64Array view over an ArrayBuffer.
On Sun, Mar 18, 2018 at 9:33 PM, Michał Wadas <[email protected]> wrote:
> Fact: JSON allows arbitrary precision numbers.
> Problem: JavaScript is unable to express these numbers.
>
> Proposed solution: introduce JSON.safeParse. This method will work as
> JSON.parse, but throwing on values that can't be accurately represented by
> IEEE 754 64-bit float.
>
> Alternative: allow user to specify number class - eg. by adding options
> object with optional method "parseNumber", overwriting default behaviour of
> using builtin number type.
>
> Any thoughts on this?
>
> _______________________________________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
>
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss