I have some json data that looks like:
{"p": {"d": {"a" : {"r": "foo","g": 1 },"b": {"r": "bar","g": 2 } },"c": {"e": {"r": "baz","g": 1 } }, ... }}
I want something like:
{"d": [ "a","b" ],"c": ["e" ]}
I can get the list of keys on the first level under "p" with jq '.p|keys'
, and the structure and keys on the second level with jq '.p|map(.|keys)'
, but I can't figure out how to combine it.