Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jq: error: round/0 is not defined at <top-level>

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?

like image 817
barl0g Avatar asked Oct 23 '25 17:10

barl0g


1 Answers

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
like image 99
oguz ismail Avatar answered Oct 26 '25 07:10

oguz ismail



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!