Reputation: 35
Given a json object (stored as bash variable $test)
{
"foo": {
"name": "my foo"
},
"bar": {
"name": "my bar"
}
}
If I want to output
{
"foo": {
"name": "my foo"
}
}
It looks like I have to use
$ jq '. | with_entries(select(.key == "foo"))' <<<$test
{
"foo": {
"name": "my foo"
}
}
Is there a simpler method to achieve same outcome?
Upvotes: 0
Views: 74