You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 10, 2019. It is now read-only.
I don't think outputting a string is a good default behavior here, since it would not (and cannot) parse back to a BigInt. You can of course trivially make stringify do the thing you want already, as you've pointed out.
@bakkot, there's prior art for allowing JSON.stringify (to string mapping), but not JSON.parse with Date-objects.
figuring out how to idiot-proof serializing and passing-around 64bit integers to-and-fro
browser <-> server <-> databases
is a big enough industry-painpoint in my mind, that BigInt should try to address it in some form.
even without JSON.parse, having a standardized JSON.stringify for BigInt to plain-strings, would still be tremendously helpful in industry by having everyone agree to a common serialization format.
Description
Current implementation (in Chrome) throws on BigInt strinigify:
I think it would make sens if a string mapping would be provided (similar to
Date
mapping provided withdate.toISOString()
method).Example
This is an example and that currently works:
It produces a valid(!) JSON:
A parser could then be provided to recognize and parse BigInt if required.
The text was updated successfully, but these errors were encountered: