I have done a lot of research on stackoverflow but cannot find any related post.
assume I have a json like
{
"talk": {
"docs": {
"count": 22038185,
"deleted": 626193
},
"store": {
"size_in_bytes": 6885993125,
"throttle_time_in_millis": 1836569
}
},
"list": {
"docs": {
"count": 22038185,
"deleted": 626193
},
"store": {
"size_in_bytes": 6885993125,
"throttle_time_in_millis": 1836569
}
}
}
I want to filter out "store" field in all keys to get an output like
{
"talk": {
"docs": {
"count": 22038185,
"deleted": 626193
}
},
"list": {
"docs": {
"count": 22038185,
"deleted": 626193
}
}
}
How can I achieve it with jq?
Use del
and recurse
together.
jq 'del(recurse|.store?)' foo.json
You can also the short ..
for recurse
with no arguments:
jq 'del(..|.store?)' foo.json
The ?
prevents errors when recurse
reaches something for which .store
is an invalid filter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With