I have been trying to extract only certain data from a JSON file. I managed to decode the JSON and get the wanted data into a python dict. When I print out the dict it shows all the wanted data, but when I try to write the dict into a new file, only the last object gets written.
One thing that I can't understand is also why when I print the dict I get multiple dicts objects instead of 1 as I would expect.
My code:
import json
input_file=open('json.json', 'r')
output_file=open('test.json', 'w')
json_decode=json.load(input_file)
for item in json_decode:
my_dict={}
my_dict['title']=item.get('labels').get('en').get('value')
my_dict['description']=item.get('descriptions').get('en').get('value')