json - jq - select objects with given key name -
i've got arbitrary structure many levels, etc. need select objects contain key named updatedate
. how do jq? came 1 way produces errors on invalid data types when visits leaf have grep out:
jq 'recurse(.[]) | has("updatedate")' | grep -fv error
i don't understand how check types or leaves , suspect there simpler way achieve want?
in 1.4 can just:
jq '..|.updatedate?'
if you're stuck 1.3 can use longer program so:
jq 'recurse(if type == "array" or type = "object" .[] else empty end) | if type == "object" .updatedate else empty end'
Comments
Post a Comment