Extract part of data from JSON file with python
Your code creates new dictionary object for each object with:
my_dict={}
Moreover, it overwrites the previous contents of the variable. Old dictionary in m_dict is deleted from memory.
Try to create a list before your for loop and store the result there.
result = []
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')
my_dict['id']=item.get('id')
print(my_dict)
result.append(my_dict)
Finally, write the result to the output:
back_json=json.dumps(result)
Printing the dictionary object aims to help the developer by showing the type of the data. In u'Diego Vel\xe1zquez', u at the start indicates a Unicode object (string). When object using is printed, it is decoded according to current language settings in your OS.