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

杀马特。学长 韩版系。学妹 提交于 2020-05-30 07:37:45

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!