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 | true) as $p | [ ( [ $p[] | tostring ] | join(".") ), ( getpath($p) | tojson )] | join(": ")' short.json
Easy(er) to read version:
jq -r '
paths(scalars | true) as $p
| [ ( [ $p[] | tostring ] | join(".") )
, ( getpath($p) | tojson )
]
| join(": ")
' short.json
Result:
Reservations.0.Instances.0.ImageId: "ami-a"
Reservations.0.Instances.0.InstanceId: "i-a"
Reservations.0.Instances.0.InstanceType: "t2.micro"
Reservations.0.Instances.0.KeyName: "ubuntu"
And because I want the bonus points, here's a hacky sed you can tack on to get the output you want:
... | sed "s/^/\'./; s/:/\':/; s/\.0/[]/g"
Which outputs:
'.Reservations[].Instances[].ImageId': "ami-a"
'.Reservations[].Instances[].InstanceId': "i-a"
'.Reservations[].Instances[].InstanceType': "t2.micro"
'.Reservations[].Instances[].KeyName': "ubuntu"