JSON support for BigInt in Chrome/V8

Anders Rundgren anders.rundgren.net at gmail.com
Sat Jul 28 15:52:14 UTC 2018


On 2018-07-28 16:52, Ranando King wrote:
> Why not just use DataURL syntax, something like this:
> 
> ```js
> {
>    "field1": "data:json/bigint,12345678901234567890123456789012345678901234567890123456789012345678901234567890",
>    ...
> }
> ```
> This way, even as other objects pop up to be serialized, all that would be needed is another mime type in the format "json/<typename>". I could even see letting the "<typename>" portion hold the non-lowercased, original class name to make it even faster to deserialize such fields without knowing all possible mime types in advance. Still 100% compatible with existing JSON. Still 100% human readable/writable. Very easy to implement, and self consistent.
> 

I think the issue is rather: What problem do we want to solve?

It is pretty obvious that there is no "perfect" solution.

XML proves that there is no need for explicit type information in an information exchange format. Most sophisticated systems map keys in some way making explicit type information redundant.  That JSON do have a set of distinct data types is great, but extending that type scheme outside of the original JavaScript core, IMO only creates problems.  Nobody (in their right mind) would even think of designing a typed format where everything from a byte to BigDecimal would be represented as a single type.

Anders


More information about the es-discuss mailing list