Python: read object from file in python

UPDATE

By simply reading a json file it is not in json form. You need to parse it with json module.

import json
with open('data.json', 'r') as f:
  data = json.loads(f.read())

for _ in data['name']:
  print(_, data['name'][_])

Leave a Comment