I need to display users if their realm is internal.
Input:
[
{
"name": "A_A",
"uri": "https:test/test",
"realm": "internal"
},
{
"name": "B_B",
"uri": "https:test/test",
"realm": "internal"
},
{
"name": "C_C",
"uri": "https:test/test",
"realm": "external"
}
]
Tried with:
jq 'if .[].realm == "internal" then .[].name else empty end'
But the problem is that it is listing all the users.
Expected output:
A_A , B_B
.[] | (if .realm == "internal" then .name else empty end)
. You have to put your conditional after you iterated into the individual item you want to test. – Charles Duffy Feb 19 '19 at 16:42