How can I avoid jq truncating long decimal

2019-07-22 03:29发布

问题:

How can I prevent jq from truncating long decimal values?

For example:

echo '18302628978110292481' | jq .

result: 18302628978110292000

回答1:

Javascript does not support such big numbers and so does jq. The integer size is 2^53. Check this

To make it work, you'll need to treat them as strings:

echo '"18302628978110292481"' | jq .
# Prints "18302628978110292481"


标签: decimal jq