I found this Q/A with the solution to print all the keys in an object:
jq -r 'keys[] as $k | "\($k), \(.[$k] | .ip)"'
In my case I want to perform the above but on a sub-object:
jq -r '.connections keys[] as $k | "\($k), \(.[$k] | .ip)"'
What is the proper syntax to do this?
Best Answer
Simply pipe to
keys
function:Sample
input.json
:The output: