3 ms·
This seems like it unnecessarily couples the JSON representation to the language types. JSON numbers are already arbitrarily precise. How you represent the type
by Spivak 8y ago
This seems like it unnecessarily couples the JSON representation to the language types. JSON numbers are already arbitrarily precise. How you represent the type is up to the parser.
JSON.stringify(5n) === "5"
JSON.parse("5") === Number(5)
JSON.parse("5000000000000000000") => Error
JSON.parse({ use_bignum: true }) === 5000000000000000000n
A project that does something like this:
https://www.npmjs.com/package/json-bignum https://www.npmjs.com/package/json-bignum