3 ms·
While there's a few gotchas, rolling your own JSON parser isn't necessarily a ton of work. Or perhaps a proposal could be written to give numbers emitted by JS
by daxterspeed 8y ago
While there's a few gotchas, rolling your own JSON parser isn't necessarily a ton of work.
Or perhaps a proposal could be written to give numbers emitted by JSON.parse a "raw" property, so they could be decoded using BigInt?
- elmigranto 8y agoNo need for custom parser. Right now, you can use custom format with reviver and serializer functions (2nd arg to serialize / parse). Say, have them serialize as string `^bigint[\d]+$` and revive appropriately.
- daurnimator 8y agoBut the point is to support large numbers with the traditional syntax. e.g. so that {"foo": 1234567890123456789012345678901234567890} doesn't lose precision.
- elmigranto 8y agoGiven that `int + bigint` throws in JS, this exact thing will never happen imo, otherwise, you can't differentiate between types. Maybe something like `{"x": 10n}`, but at that point, might as well do reviver, especially if you already agreed on a format and use some to parse out class instances vs plain objects.