How do I get a specific result in the for each json loop?

I am using for each to loop through a json object that looks like this:
image

How do I get each ID without getting them all from the for each so I can use it outside of the loop?

image

Thank you