0

I have a json file that looks like this JSON_FILE: JSON_FILE

It contains nested dictionary. I want to retrieve the key annotations(appears one time in file). Specifically all the values against key image_id(appears many times in file) and store it in a separate file. How do I do it in PYTHON

depperm
  • 10,606
  • 4
  • 43
  • 67
RA FI
  • 33
  • 7

1 Answers1

0

I have been able to resolve this

import json
    
with open("myfile.json") as f:
  data_retreived= json.load(f) 
a=data_retreived["annotations"]
    
    
        
myfile = open('data.txt', 'w') 
for f in a:   
  myfile.write("%s\n" % f['image_id'])   
  #print(f['image_id']) 
myfile.close()
RA FI
  • 33
  • 7