Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (50.2k points)
Can anyone tell me how to read a JSON file in Python?

1 Answer

0 votes
by (108k points)

For reading a JSON file in Python, you can refer to the below code:

# json file  

import json  # Opening JSON file 

f = open('data.json',)  # returns JSON object as a dictionary 

data = json.load(f)  # Iterating through the json list 

for i in data['emp_details']: 

    print(i) 

f.close() # Closing file 

If you are looking for an online course to learn Python, I recommend this Python Online Course program by Intellipaat.

Related questions

...