solemnify solemnify - 6 months ago 31
JSON Question

Running bash commands for each JSON item through jq

I would like to run a bash command for each field in a JSON formatted piece of data by leveraging jq.

"apps": {
"firefox": "1.0.0",
"ie": "1.0.1",
"chrome": "2.0.0"

Basically I want something of the sort:

foreach app:
echo "$key $val"


Assuming you wanted to list out the key/values of the apps object:

$ jq -r '.apps | to_entries[] | "\(.key)\t\(.value)"' input.json