On 2018-03-19 14:43, Mike Samuel wrote:
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.
That's a good idea. I guess it would permit decimal & friends to put in
strings as well because this is used by quite a bunch of people?
Anders
On Sun, Mar 18, 2018 at 9:33 PM, Michał Wadas <[email protected]
<mailto:[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] <mailto:[email protected]>
https://mail.mozilla.org/listinfo/es-discuss
<https://mail.mozilla.org/listinfo/es-discuss>
_______________________________________________
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