Large integer are changed, even if only other parameter are touched
ujaehrig opened this issue · 2 comments
When running an assign on a JSON with a large integer, the integer is changed. This might probably be caused by handling it as a double?
Example:
echo '{"id":6000000000000002181,"flag":false}' | rq --format=compact 'assign { "flag":true }'
results in:
{"flag":true,"id":6000000000000002048}
Hey @ujaehrig, yes this is due to the fact that Javascript only supports representing numbers up to 2^53-1 (usually encoded as a double
but not necessarily). Not sure how to solve this tbh...
Yes, I checked the specs in the meantime and saw that JSON has only the double precision number type. My example had used Java-Jackson as JSON processor which can also handle long ints.
Nevertheless, it's unfortunate, that rq changes the value, even it's not touched directly. Maybe a warning (something like "int number too large" or "int number precision loss") could be the first solution?