Suppose I have a json file. I want to filter this file to only output content where a given pattern appears in anywhere in the full path or leaf node value. For example, suppose the json file has below content:
{ "a": "foo", "b": "bar", "c": { "d": "foo", "e": "bar" }, "aa": { "foo": [ 1, 2, 3 ], "bar": { "foo": false } }}And the pattern is "foo". Then, the output should be as follows.
{ "a": "foo", "c": { "d": "foo" }, "aa": { "foo": [ 1, 2, 3 ], "bar": { "foo": false } }}So, what should the jq command be?