问题
round function in jq doesn't work.
$ jq '10.01 | round'
jq: error: round/0 is not defined at <top-level>, line 1:
10.01 | round
jq: 1 compile error
$ jq --help
jq - commandline JSON processor [version 1.5-1-a5b5cbe]
What I need to do?
回答1:
Seems like round
is unavailable in your build. Either upgrade jq or implement round
using floor
:
def round: . + 0.5 | floor;
Usage example:
$ jq -n 'def round: . + 0.5 | floor; 10.01 | round'
10
来源:https://stackoverflow.com/questions/56593531/jq-error-round-0-is-not-defined-at-top-level