Skip to content

Python load() function

  • by

Python load() function is used to read JSON data from files and String. Python built-in module JSON provides the following two methods to decode JSON data.


The json.load() method returns data in the form of a Python dictionary.

Python load() function example

A simple example code read JSON data from a file and converts it into a dictionary. Used the open() function to read the JSON file. Then, the file is parsed using json.load() method which gives us a dictionary named data.

import json

with open("data.json", "r") as read_file:
    res = json.load(read_file)

    for key, value in res.items():
        print(key, ":", value)


Python load() function

Mapping between JSON and Python entities while decoding

Python JSON conversion table:

number (int)int
number (real)float

Do comment if you have any doubts or suggestions on this Python function topic.

Note: IDE: PyCharm 2021.3.3 (Community Edition)

Windows 10

Python 3.10.1

All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.