json - Recursive search values by key -
i have json this:
{ "a": { "error": null }, "b": { "c": {"error": "error string"}}, "c": { "d": {"error": null}}, "d": { "error": "err str"} }
end want find values of error keys not null.
for example should return
"error string" "err str"
how can it? possible jq?
use ..
iterate recursively, , .error
values. if they're null
, remove them:
jq '.. | .error? // empty'
alternatively, instead of using empty
can select elements strings strings
:
jq '.. | .error? | strings'
Comments
Post a Comment