jQ output code example
Example 1: jq filter array
$ json='[{"genre":"deep house"}, {"genre": "progressive house"}, {"genre": "dubstep"}]'
$ echo "$json" | jq -c '.[] | select(.genre | contains("house"))'
{"genre":"deep house"}
{"genre":"progressive house"}
Example 2: jq select
$ jq '.[] | select(.location=="Stockholm")' json
{
"location": "Stockholm",
"name": "Walt"
}
{
"location": "Stockholm",
"name": "Donald"
}
Example 3: jq list top nodes
echo '{"node1":"foo", "node2":"bar","node3": {"inner-node": "baz"}}' | jq '. |=keys'
[
"node1",
"node2",
"node3"
]