JSON support for BigInt in Chrome/V8

Andrea Giammarchi andrea.giammarchi at gmail.com
Tue Jul 17 16:04:57 UTC 2018


My idea is that `JSON.stringify(new Uint8Array([1, 2, 3]));` is also an
issue, not only BigInt.

if every value could be represented as `{{type: 'BigInt', value:
'55555555'}, {new: 'Uint8Array', value: [1, 2, 3]}, {type: 'string', value:
'dastring'}, {type: 'number', value: 123}, {new: 'String', value: 'as
wrap'}}` and resurrected later on it's basically problem solved except for
Weak* and Symbol, unless it's a global one, and it'd be OK.

That transformation would be compatible also with all circular-json like
libraries I know (or I've written).

Regards



On Tue, Jul 17, 2018 at 5:44 PM Cyril Auburtin <cyril.auburtin at gmail.com>
wrote:

> It would be great to have
> ```js
> JSON.stringify({x: 5n, y: BigInt('6')}) === '{"x":5n,"y":6n}'
> JSON.parse('{"x": 3n}') // {x: 3n}
> ```
> I don't know how feasable it would be, maybe have a new JSON5 object if
> JSON can't be changed for some reasons
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20180717/d848cb16/attachment-0001.html>


More information about the es-discuss mailing list