I have a JSON lines file with summary
fields and other fields. I would like to delete all of the summary fields using JQ. This is my input:
{"object1": {"summary":"Some summary I want removing", "keepMe":"please"}}
{"object2": {"summary":"Delete me too!", "keepMe":"pretty please"}}
and this is the desired output:
{"object1": {"keepMe":"please"}}
{"object2": {"keepMe":"pretty please"}}
There are several possible interpretations of the Q.
A simple approach that will solve the simplest interpretation would be to use:
map_values(del(.summary))
If you want to eliminate the "summary" field wherever it occurs, no matter how deeply nested, then I'd use walk/1
, e.g.
walk(if type == "object" then del(.summary) else . end)
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