JQ Tips

官方文档:https://stedolan.github.io/jq/manual

jq '.jobs[] | select(.id=="afs_agent")'

jq '.jobs[] | select(.id=="afs-agent" or .id == "afs_agent")'

jq '.jobs[] | select(.id=="afs_agent") | .appid + "\t"+ .phytag' -r

jq -r '.[] | select(.name=="AAA") | (.members|tostring) +" "+ .id test'

jq --arg foo 123 '.physicals[] | $foo + " " + .tag ' -r

jq '.data.strategy.configurations[] | has("mix_user")'

jq '.hosts[] | select(.blacked | contains("Internal"))'

jq '.hosts[] | length'

jq 'select((.widgets | length) > 0 and (.users | length) > 0)'

jq '."resource.priority"'

jq '. | to_entries | .[] | .key + " " + (.value | length | tostring)' -r

jq '. | to_entries | map(select(.value.name == $queue and .value.type == "GROUP")) | .[].value.name'

jq '{"cluster": .master_id, "ins": .instances[]}'

Use jq to filter objects list with regex
https://til.hashrocket.com/posts/uv0bjiokwk-use-jq-to-filter-objects-list-with-regex