0 votes
1 view
in Python by (12.5k points)
edited by

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

1 Answer

0 votes
by (24.8k 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:

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...