How can I extract all key names, even in nested objects with jq? For example, I have json:
{ \"a\": 1, \"b\": { \"c\": 2 } }
and I wa
Short jq solution:
jq -r '[paths | join(".")]' jsonfile
The output:
[ "a", "b", "b.c" ]
paths function outputs the paths to all the elements in its input
paths
join(".") - to concatenate keys within hierarchical paths
join(".")