Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (19.9k points)
edited by

How do I parse a JSON file in python to read data from it?

1 Answer

0 votes
by (25.1k points)

Python has a built in module named 'json'. You can use it to parse json data.

Since you have your json data in a file all you have to do is read the file and parse it using json module.

Also you can make the output pretty by using the pprint method.

You can do it like this:

import json

from pprint import pprint

data = json.load(open('data.json'))

pprint(data)

You can learn more about python using this video:

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
+2 votes
2 answers
0 votes
1 answer
asked Jul 2, 2019 in Python by Sammy (47.6k points)

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...