|
Answer» 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

|