You can use the all function to reduce an array of Booleans* to true if all the Booleans are true. jq will output that value, which you can capture using command substitution.

result=$(jq 'map(.value) | all' tmp.json)

You may not need the actual output, though. It may be sufficient to use the --exit-status option (short form -e) to test if jq would return true or not.

if jq -e 'map(.value) | all' tmp.json > /dev/null; then
   echo "All were true"
   echo "At least one was false"

* Among other things; see @peak’s comment below

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top