Assuming this is the input
>echo '{"A": {"x": 1}, "B": {"x":2}, "C":{"x":3}}' | jq '.'
{
"A": {
"x": 1
},
"B": {
"x": 2
},
"C": {
"x": 3
}
}
I would like to get the return object of "x" == 2.
The only way i know of how to achieve that is thru this
>echo '{"A": {"x": 1}, "B": {"x":2}, "C":{"x":3}}' | jq '.[] | select(.x==2)'
{
"x": 2
}
Is there a way to have jq return me like this instead?
{
"B": {
"x": 2
},
}