How can i select / filter all connection with field.usesEncryption is true using jq from JSON data below
{
"connections": {
"connection": [
{
"field": [
{
"id": "url",
"encryptedValueSet": false,
"usesEncryption": false,
"componentOverride": false,
"useDefault": false
},
{
"id": "user",
"encryptedValueSet": false,
"usesEncryption": false,
"componentOverride": false,
"useDefault": false
},
{
"id": "password",
"encryptedValueSet": true,
"usesEncryption": true,
"componentOverride": false,
"useDefault": false
}
],
"id": "3ea89002-51f5-4369-9539-63c3bd406a64"
}
]
}
}
I tried following but not working as desired
jq '. | select(.connections.connection[].field[] | .usesEncryption==true)' EnvironmentExtensions.json
jq '. | .connections.connection[].field[] | select(.usesEncryption==true)' EnvironmentExtensions.json
2
Answers
Filter below works but the top level structure is lost from output
To modify the inner array, either use (requires jq 1.7):
or (works with jq 1.6)