Here is jq
getting field a1
:
$ echo '{"a": {"a1": 1}, "b": {"a1": 2}}' | jq -r ".[] | .a1"
1
2
I'd like to get the keys a
and b
as well, and output a flat result, i.e.
$ echo '{"a": {"a1": 1}, "b": {"a1": 2}}' | jq -r "<magic here>"
a 1
b 2
Suggestions?