Bash-jq-examples
Jump to navigation
Jump to search
Some examples of using jq to do filtering..
raw jason:
{
"1": [
{
"id": "123456789",
"accountId": "a1-supplies-01234",
"accountName": "a1-supplies",
"status": "LIVE",
"customerId": "A1 Supplies",
"customerType": "display"
}
]
}
Map will iterate through the array(s) looking for key status, and value LIVE
<json here> | jq -c 'map(select(.[].status | contains ("LIVE")))' | jq
- Running the output through jq again puts the line breaks back in place
- contains in a search DOES honor pipes
contains ("LIVE"|"DEAD")