Repository navigation
taka512 edited this page Nov 25, 2021
·
4 revisions
brew install jq
cat tmp.json | jq '.total_count'
https://dev.classmethod.jp/articles/road-to-jq-master-apprentice/
cat tmp.json | jq '.[]'
「-」をつけると降順にソート
cat tmp.json | jq 'sort_by(.company_id,-.warehouse_base_id)'
-rオプション を利用すると、ダブルクォートが取り除かれます。
$ cat tmp.json | jq -r '.name'
$ cat tmp.json | jq -r 'map({ name: .name, owner_id: .owner.id })'
items配列 から size の値が 25 より大きい要素を抽出
$ cat tmp.json | jq 'map(select( .size > 25 ))'
items配列 から owner.type の値が Organization である要素を抽出
$ cat tmp.json | jq 'map(select( .owner.type == "Organization" ))'
cat tmp.json |jq -r '.[] | [.size,.cnt] | @csv'
cat tmp.json |jq -r '.[] | [.size,.cnt] | @tsv'