Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Deserializing JSON Data

Give Feedback

In this video, you’ll learn how to deserialize JSON data into Python objects you can use in your program.

The json module exposes two methods for deserializing JSON

load() will load JSON data from a file-like object. We use this method when we’re reading in data from a file-like object.

loads() will load JSON data from a string containing JSON-encoded data.

Unless your encoded data is something very simple, these methods will most likely return a Python dict or list containing your deserialized data.

This chart shows how JSON data is deserialized into Python objects

JSON Python
object dict
array list
string str
number (int) int
number (real) float
true True
false False
null None

Serialization and Deserialization are not perfectly inverse operations! This means that deserialization may not return to you the exact object you serialized.

For example, a Python tuple will be serialized as a JSON array. When we deserialize the array, we will get a Python list containing the data in the tuple. If we want our original tuple object back, we need to pass this list into the initializer for the tuple.

Comments & Discussion

Tonya S on June 29, 2019

Great tutorial on JSON! Can you tell me which code editor you are using?

Matt L on July 29, 2019

Tonya - Austin seems to be using Visual Studio Code by Microsoft.

Andrew E on Dec. 11, 2019

Really enjoying this tutorial, thanks Austin :)

sroux53 on May 13, 2020

Excellent!

Become a Member to join the conversation.