| Write a code to read JSON file and print data of JSON in Python?
Code to read JSON file we use json.load() method and this accepts file object and then parses JSON data.
json.load(file object)
Now we write code to handle below testData.json file and print output of data.
#python code to read a JSON file
import json
#opening json file
fobj = open('TestData.json',)
#this return JSON object as a dictionary
data = json.load(fobj)
#now iterate through JSON list
for i in data["Course_details"]:
print(i)
#Closing file now
fobj.close()
Now output of above code we will get below value
| | |