3

jq 中的 round 函数不起作用。

$ 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]

我需要做什么?

4

1 回答 1

5

似乎round在您的构建中不可用。升级 jq 或round使用floor

def round: . + 0.5 | floor;

使用示例:

$ jq -n 'def round: . + 0.5 | floor; 10.01 | round'
10
于 2019-06-14T07:58:25.740 回答