I want to list the keys of a nested object of my document.
For example, I want the keys in the "a"
object: "a1", "a2"
The sample document:
{
"a": {
"a1": "hello",
"a2": "world"
},
"b": {
"b1": "bonjour",
"b2": "monde"
}
}
I know I can use keys
, but it seems to work only for the first level object: cat my.json | jq keys
will output a, b
.
So far I chain two calls with jq
but I wonder if we can do it in one call ?
cat my.json | jq .a | jq keys
--> a1, a2