条件判断时,一定要有 else 和 end。
1
2
3
4

cat huaping2array.json | jq 'map(if .media_type == "video" then .pkt_pts else "" end )'

echo '[0, 1, 2, 3]' | jq 'map(if . == 0 then "zero" elif . == 1 then "one" elif . == 2 then "two" else "many" end)'
将剪贴板的内容json格式化
1
alias "jsfmt=xclip -o |jq"

参考 https://mozillazg.com/2018/01/jq-use-examples-cookbook.html

jsfmt ‘.responses | .[].hits.hits[]._source.app’