Skip to content Skip to sidebar Skip to footer

How To Grab Values From Key:value Pairs In Parsed Json In Python

I am trying to extract data from a JSON file. Here is my code. import json json_file = open('test.json')

Solution 1:

The source you provide cannot be read by json, there are two comma's in there that you have to delete (the one on the fourth line from the bottom, and the one two lines above dataObjects. Only after that does the json module parse without error:

import json

json_file = open('test.json')
data = json.load(json_file)
do = data['dataObjects'][0]
print do['identifier']
print do['description']
json_file.close()

Post a Comment for "How To Grab Values From Key:value Pairs In Parsed Json In Python"