Re: "Stupid" JSON Number Serialization Question

14 views
Skip to first unread message

kai zhu

unread,
May 26, 2018, 2:29:04 PM5/26/18
to es-di...@mozilla.org, nod...@googlegroups.com
slightly off-topic, but this would be relevant for nodejs database-driver authors contemplating BigInt support.

here's the the tentative roadmap for indexeddb support for bigint [1]:

Design decisions:

  • BigInts compare greater than Number and less than everything else
  • No type coercion between BigInt and Number; they are simply
    distinct, unrelated keys, even if mathematically equal
  • No BigInt autoIncrement support--53 bits should be enough for anyone

BigInts and BigInt wrappers are proposed to be made serializable, and
therefore available as IndexedDB values, in
whatwg/html#3480

Addresses #230


[1] github pull-request - Allow BigInts as IndexedDB keys #231




On 26 May 2018, at 11:47 PM, kai zhu <kaiz...@gmail.com> wrote:

fyi, there was extensive discussion on whether you can JSON.stringify BigInt, in the BigInt proposal [1].  the consensus is that you cannot [2]:

Here's the relevant JSON spec and here's the relevant String spec. Reading them, they say that JSON.stringify(1234n) throws (as discussed previously) and String(1234n) gives "1234".



[1] github issue - Support JSON serialisation of BigInt values #24

[2] github issue - spec and README.md are unclear what serialized form of BigInt looks like using .toJSON / .toString


On 20 May 2018, at 11:12 PM, Richard Gibson <richard...@gmail.com> wrote:

That seems like a question best addressed by something like JSON Schema. ECMAScript is not unique in lacking sufficient native machinery to process JSON numbers that have no IEEE 754 64-bit representation, and similar issues exist for binary data and complex types like date/time values.

On Sunday, May 20, 2018, Anders Rundgren <anders.ru...@gmail.com> wrote:
My question was really how non-ES systems preferable should "talk numbers" to ES when using JSON:
https://mail.mozilla.org/pipermail/es-discuss/2018-May/050889.html

Anders
_______________________________________________
es-discuss mailing list
es-di...@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________
es-discuss mailing list
es-di...@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Reply all
Reply to author
Forward
0 new messages