ruby / json

JSON implementation for Ruby
https://ruby.github.io/json
Other
704 stars 332 forks source link

Convert integer value exceeding the maximum numeric value in JavaScript to string #252

Open iRonin opened 9 years ago

iRonin commented 9 years ago

We have an issue with integer values served by our Rails API and consumed by EmberJS app. They are stored in the DB as bigint and they exceed the maximum numeric value in JavaScript. Isn't it something that should be handled by this gem?

flori commented 9 years ago

I don't think the concept of a maximum numeric value exists in JSON itself. It would be possible to check against some settable limit in the gem, but then do what? Shouldn't javascript promote too large integers to floats anyway?

sproot commented 9 years ago

I have exact same problem. I've tried to solve it by overriding Bignum#to_json method with no luck #254 . The idea was to convert large integers (53+ bits) to string.