JSON stands for JavaScript Object Notation. It means that a script (executable) file which is made of text in a programming language, is used to store and transfer the data. Python supports JSON through a built-in package called json. To use this feature, we import the json package in Python script. The text in JSON is done through quoted-string which contains value in key-value mapping within { }. It is similar to the dictionary in Python.
Function Used:
- json.load(): json.loads() function is present in python built-in ‘json’ module. This function is used to parse the JSON string.
Syntax: json.load(file_name)
Parameter: It takes JSON file as the parameter.
Return type: It returns the python dictionary object.
Example 1: Let’s suppose the JSON file looks like this:

We want to convert the content of this file to Python dictionary. Below is the implementation.
# Python program to demonstrate # Conversion of JSON data to # dictionary # importing the module import json # Opening JSON file with open('data.json') as json_file: data = json.load(json_file) # Print the type of data variable print("Type:", type(data)) # Print the data of dictionary print("\nPeople1:", data['people1']) print("\nPeople2:", data['people2']) |
Output :

Example 2: Reading nested data
In the above JSON file, there is a nested dictionary in the first key people1. Below is the implementation of reading nested data.
# Python program to demonstrate # Conversion of JSON data to # dictionary # importing the module import json # Opening JSON file with open('data.json') as json_file: data = json.load(json_file) # for reading nested data [0] represents # the index value of the list print(data['people1'][0]) # for printing the key-value pair of # nested dictionary for looop can be used print("\nPrinting nested dicitonary as a key-value pair\n") for i in data['people1']: print("Name:", i['name']) print("Website:", i['website']) print("From:", i['from']) print() |
Output :

Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
Recommended Posts:
- How To Convert Python Dictionary To JSON?
- Python - Difference between json.dump() and json.dumps()
- Python - Difference Between json.load() and json.loads()
- Python | Convert flattened dictionary into nested dictionary
- Python | Convert nested dictionary into flattened dictionary
- Python | Convert string dictionary to dictionary
- Python - Convert Dictionary Value list to Dictionary List
- Python | Ways to convert string to json object
- Convert JSON to CSV in Python
- Convert Text file to JSON in Python
- Python - Convert JSON to string
- How to convert pandas DataFrame into JSON in Python?
- Convert CSV to JSON using Python
- Convert JSON data Into a Custom Python Object
- Convert multiple JSON files to CSV Python
- Convert PyMongo Cursor to JSON
- Python | Pretty Print a dictionary with dictionary value
- Regular Dictionary vs Ordered Dictionary in Python
- Python | Dictionary initialization with common dictionary
- Python - Update dictionary with other dictionary
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

