Create test.json:
cat << 'EOF' > ./test.json
[
{
"name": "First1 Last",
"email": "[email protected]",
"state": "A"
},
{
"name": "First2 Last",
"email": "[email protected]",
"state": "S"
}
]
EOF
Filter on state=A, format output of name and email:
cat test.json | jq -r 'map(select(.state | contains ("A"))) | .[] | .name as $name | .email as $email | "Name: \($name), Email: \($email)"'
Output:
Name: First1 Last, Email: [email protected]