How to use json.load() in Python
This tutorial is How to use json.load() in Python. the full-form of JSON is (JavaScript Object Notation). Python built-in package called JSON. A JSON object contains data in the form of a key/value pair. json.load() takes a file object and returns the JSON object.
Syntax
json.load(file_object)
The JSON looks like this: data.json
Example
import json
f = open('data.json')
data = json.load(f)
for i in data['data']:
print(i)
f.close()
Output
{'id': 1, 'first_name': 'Elle', 'email': 'emanwell0@smugmug.com', 'gender': 'Female'}
{'id': 2, 'first_name': 'Algernon', 'email': 'agerrelts1@blogtalkradio.com', 'gender': 'Male'}
{'id': 3, 'first_name': 'Karisa', 'email': 'kbergen2@w3.org', 'gender': 'Female'}
{'id': 4, 'first_name': 'Daryl', 'email': 'dgaudon3@squidoo.com', 'gender': 'Female'}