So I have this input to jq:
[
"foo",
{
"a": 1,
"b": 2
},
{
"a": 1,
"b": 3
},
{
"a": 2,
"b": 2
}
]
and I want to select all objects where b is 2 ideally as an array:
[
{
"a": 1,
"b": 2
},
{
"a": 2,
"b": 2
}
]
But the string in the list makes that difficult.
If I try:
.[]| select(.b == 2)
Then I get the error:
jq: error (at /tmp/data.json:14): Cannot index string with string "b"
Any help?