In this video, you’ll learn how to deserialize JSON data into Python objects you can use in your program.
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
list containing your deserialized data.
This chart shows how JSON data is deserialized into Python objects
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
Tonya Sims on June 29, 2019
Great tutorial on JSON! Can you tell me which code editor you are using?