intridea/multi_json

Incorrect precision on json load

BS062721 opened this issue · 1 comments

We are trying to parse JSON using MultiJson.load, our values comes as numbers rather than strings and we are loosing precision on it (specially trailing zeros precision)

Example:

MultiJson.load({"value":1.00}) => 'value' => 1.0
MultiJson.load({"value":1.420}) => 'value' => 1.42

I've tried switching adapters to oj but found same issue
Is there any configuration we can use to keep precision as is?

rwz commented

Numbers don't support precision like that. In ruby, javascript, and JSON 1.42 is the same thing as 1.420. If you want precision, you should be using strings.