2019年8月16日 星期五

[jq] jq: error (at :0): string (" ") and number (1) cannot be added


jq: error (at <stdin>:0): string (" ") and number (1) cannot be added

在使用join 時,出現
jq: error (at <stdin>:0): string (" ") and number (1) cannot be added
原來是元素裏面有 string 與 number ,
不過看文件,下面的例子是可以正常執行的。
 echo '["a",1,2.3,true,null,false]' | jq -r 'join(" ")'

a 1 2.3 true  false

string and number cannot be used for join() · Issue #1595 · stedolan/jq https://github.com/stedolan/jq/issues/1595
看了一下 jq的版本,原來ubuntu內的是 1.5
根據這個issue,1.6後已經內部轉換成string了。

只好看看有無新的 1.6 版

wget https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64
sudo mv /home/peicheng/Downloads/jq-linux64 /usr/bin
ln -s /usr/bin/jq-linux64 /usr/bin/jq


沒有留言:

張貼留言