News for hackers. Stuff that matters.
Re:Adding BigInts to V8 by spullara on Wednesday May 02, 2018 @05:30PM (#16981318)
Not as useful as it could be since it has special syntax that isn't supported in JSON where not having 64-bit ints is one of the bigger issues.

https://webapplog.com/decreasing-64-bit-tweet-id-in-javascri...

The JSON use case was even one of the motivations behind BigInt in the first place:

https://twitter.com/sampullara/status/981634718964707328

Re:Adding BigInts to V8 by daxterspeed on Wednesday May 02, 2018 @06:27PM (#16981708)
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?

Re:Adding BigInts to V8 by elmigranto on Wednesday May 02, 2018 @06:48PM (#16981833)
No 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.
Re:Adding BigInts to V8 by daurnimator on Thursday May 03, 2018 @01:48AM (#16983613)
But the point is to support large numbers with the traditional syntax.

e.g. so that {"foo": 1234567890123456789012345678901234567890} doesn't lose precision.

Re:Adding BigInts to V8 by elmigranto on Thursday May 03, 2018 @07:32AM (#16984998)
Given 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.

Re:Adding BigInts to V8 by Cthulhu_ on Thursday May 03, 2018 @09:10AM (#16985632)
Probably best to represent long numbers as strings in json; json doesn't support a lot of JS's features.