Skip to main content
1 of 4
user1794469
  • 4.2k
  • 1
  • 27
  • 42

I'm not super knowledgeable on jq but I found this on the interwebs and I think it will work in your case:

Cut and paste version:

jq -r 'paths(scalars) as $p  | [ ( [ $p[] | tostring ] | join(".") ), ( getpath($p) | tojson )] | join(": ")' short.json 

Easy(er) to read version:

jq -r '
paths(scalars) as $p
  | [ ( [ $p[] | tostring ] | join(".") )
    , ( getpath($p) | tojson )
    ]
  | join(": ")
' short.json
user1794469
  • 4.2k
  • 1
  • 27
  • 42