I can get top-level JSON keys with jq
as
jq 'keys'
E.g., see this question: Get key names from JSON file using jq
And I can enable recursion in jq
:
jq '..'
As in: Recursive search values by key
But jq '.. | keys'
returns jq: error at <stdin> string has no keys
.
Just ignore keys when they are absent for some values in JSON:
jq '.. | keys?'
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