python get json content from file 1

python get json content from file

import json

with open('data.json') as json_file:
    data = json.load(json_file)
    for p in data['people']:
        print('Name: ' + p['name'])
        print('Website: ' + p['website'])
        print('From: ' + p['from'])
        print('')

Here is what the above code is Doing:
1. We open the file data.json and read the contents into a variable.
2. We load the JSON data into a Python variable.
3. We loop through the people in the data variable.
4. We print the name, website, and from where the person is from.

Similar Posts