To indiscriminately delete all request.cookies:
jq 'del(.. | .request?.cookies?)' www.ibm.com.har
As an example, given this JSON file:
$ jq -M . /tmp/hartest.json
{
"one": {
"foo": {
"bar": true,
"baz": 23
}
},
"two": {
"foo": {
"bar": "Hello",
"baz": "World"
}
},
"three": {
"fu": {
"bar": "gone",
"baz": "forgotten"
}
}
}
I can get rid of all 'bar' keys with this command:
jq -M 'del( .. | .bar?)' /tmp/hartest.json
Running the before and after through diff
:
$ diff <(jq -M . /tmp/hartest.json) <(jq -M 'del( .. | .bar?)' /tmp/hartest.json )
4d3
< "bar": true,
10d8
< "bar": "Hello",
16d13
< "bar": "gone",
If I just wanted to get rid of '.foo.bar' only, I would use this:
jq -M 'del( .. | .foo?.bar?)' /tmp/hartest.json
which, again, running through diff
gives us:
$ diff <(jq -M . /tmp/hartest.json) <(jq -M 'del( .. | .foo?.bar?)' /tmp/hartest.json )
4d3
< "bar": true,
10d8
< "bar": "Hello",