Working With JSON Data in Python

JSON is a lightweight data-interchange format. It allows us to represent the objects in our Python programs as human-readable text that can be sent over the internet. Lots of APIs and databases use JSON for communication.

You’ll learn how to work with Python’s built-in json module to serialize the data in your programs into JSON format. Then, you’ll deserialize some JSON from an online API and convert it into Python objects.

What’s Included:

Related Learning Paths:

About Austin Cepalia

Austin is a video tutorial author at Real Python. He's currently a student working towards a degree in computer science at Rochester Institute of Technology.

» More about Austin

Each tutorial at Real Python is created by a team of developers so that it meets our high quality standards. The team members who worked on this tutorial are:

Participant Comments

Avatar image for PururinTora

PururinTora on March 2, 2022

This was awesome Guys! I learnt a lot from it. These lines were absolute highlights for me:

sorted_users = sorted(todos_by_user.items(), key=lambda x: x[1], reverse=True)
filtered_todos = list(filter(keep, todos))
Avatar image for mikesult

mikesult on Feb. 20, 2020

Great course, I really liked working with the custom type encoder/decoder. I usually type the exercises out by hand and I have been using single quotes instead of double quotes. One thing I learned was that JSON requires double quotes, single quotes don’t work. You might have mentioned that and I missed it (I think I read that somewhere and already had forgotten it). That made me fumble around for a while when I wrote out the complex_data.json using single quotes and JSON_Ex5.py didn’t work. Those are the kind of things that can trip me a bit. I appreciate learning about working with JSON. Thank you.

Avatar image for Pygator

Pygator on Aug. 27, 2019

Thanks. Great explanations! JSON has always been so mysterious.

Avatar image for Fahim

Fahim on July 9, 2019

Well explained. Thanks

Avatar image for SamR

SamR on June 17, 2019

Very helpful course. Thanks!

Avatar image for Raghunandana SK

Raghunandana SK on April 1, 2019

Yep, This really takes some time to understand . But its explained well for sure

Avatar image for ChrisF

ChrisF on March 31, 2019

Excellent course, really loved it

Avatar image for James Magruder

James Magruder on March 30, 2019

This was excellent!! However, it will take me a while to absorb it all. I may have to watch it again.

« Browse All Courses