Discussion:
[nodejs] Re: "Stupid" JSON Number Serialization Question
kai zhu
2018-05-26 16:01:59 UTC
Permalink
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 <https://github.com/whatwg/html/pull/3480>
Addresses #230 <https://github.com/w3c/IndexedDB/issues/230>


[1] github pull-request - Allow BigInts as IndexedDB keys #231
https://github.com/w3c/IndexedDB/pull/231 <https://github.com/w3c/IndexedDB/pull/231>
Here's <https://tc39.github.io/proposal-bigint/#sec-serializejsonproperty> the relevant JSON spec and here's <https://tc39.github.io/proposal-bigint/#sec-tostring-applied-to-the-bigint-type> the relevant String spec. Reading them, they say that JSON.stringify(1234n) throws (as discussed previously <https://github.com/tc39/proposal-bigint/issues/24>) and String(1234n) gives "1234".
[1] github issue - Support JSON serialisation of BigInt values #24
https://github.com/tc39/proposal-bigint/issues/24#issuecomment-290200829 <https://github.com/tc39/proposal-bigint/issues/24#issuecomment-290200829>
[2] github issue - spec and README.md are unclear what serialized form of BigInt looks like using .toJSON / .toString
https://github.com/tc39/proposal-bigint/issues/124 <https://github.com/tc39/proposal-bigint/issues/124>
kai zhu
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.
https://mail.mozilla.org/pipermail/es-discuss/2018-May/050889.html <https://mail.mozilla.org/pipermail/es-discuss/2018-May/050889.html>
Anders
_______________________________________________
es-discuss mailing list
https://mail.mozilla.org/listinfo/es-discuss <https://mail.mozilla.org/listinfo/es-discuss>
_______________________________________________
es-discuss mailing list
https://mail.mozilla.org/listinfo/es-discuss
--
Job board: http://jobs.nodejs.org/
New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/12CB7E32-7553-4CFD-886A-A242E7CE9E4F%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
Loading...