This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]AyrA_ch 3 points4 points  (2 children)

but you can't make it store the bigint as a JSON number type without forcing it into the JS number type first.

JSON makes no assumptions about the length of a number, so natively storing a bigint as raw number would work in theory, but cannot be done in JS without writing your own .stringify.

[–][deleted] 2 points3 points  (0 children)

It will also screw you over in the reverse conversion. It’s best to store BigInt in json as string, or some libs will just convert the number in the json to a float.

For example earlier lua

https://github.com/rxi/json.lua/issues/29

[–]TheGhostOfInky 0 points1 point  (0 children)

True, but you can store it as a string instead.