Working with JSON

Introduction

JSON (JavaScript Object Notation) is a lightweight, text-based format for representing structured data. It looks a lot like a mix of Python dictionaries and lists: curly braces hold key-value pairs, square brackets hold ordered sequences, and values can be strings, numbers, booleans, null, or nested objects and arrays. Because it is both human-readable and easy for programs to parse, JSON has become the default way that web APIs exchange data and that applications store settings and configuration.

In this module you have been working with files and with code that can fail at runtime; JSON sits right at the intersection of those ideas. Python's built-in json module gives you four functions to remember: json.loads and json.load turn JSON text (from a string or a file object) into Python objects, and json.dumps and json.dump turn Python objects back into JSON text (to a string or a file). You will also meet the module's limits — not every Python object is serializable, dictionary keys become strings, tuples become arrays, and malformed input raises a JSONDecodeError that your program should handle gracefully.

As you watch the videos below, pay attention to three things: the mapping between JSON types and Python types, the difference between the functions ending in 's' (string) and those without (file), and formatting options such as indent and sort_keys that make configuration files readable. Try typing the examples yourself and then deliberately break one — delete a comma or a quote — so you can see what error Python reports.

Video 1: JSON Tutorial Python | Basic Python Recipes

mCoding · 5:56 · 25,759 views · 5y ago · captions — Watch on YouTube

About this video

A concise, practical walkthrough of reading and writing JSON in Python using the standard library json module. Expect to see loading JSON from a file and from a string, dumping Python data structures back out, and the type correspondence between JSON and Python values. Source code is provided by the channel so you can follow along.

Why this video

mCoding is produced by a professional Python developer known for accurate, no-filler explanations, making this a reliable first look at json.load/loads and json.dump/dumps.

Video 2: How To Use JSON In Python

Tech With Tim · 6:11 · 248,880 views · 4y ago · captions — Watch on YouTube

About this video

A fast-paced introduction aimed at getting you productive with JSON in Python in a few minutes. It is likely to cover the basic syntax of JSON, converting between Python dictionaries and JSON strings, and saving and loading JSON data from files. The pacing suits a quick review or a second pass after the other videos.

Why this video

Tech With Tim is a widely followed Python instructor whose beginner-focused style reinforces the core four functions and the dictionary-to-JSON mental model with minimal overhead.

Video 3: Learn JSON Step-by-Step from Scratch

Automation Step by Step · 13:11 · 126,173 views · 5y ago · captions — Watch on YouTube

About this video

A language-agnostic, step-by-step introduction to JSON itself: what it is, what it is used for, how to write valid JSON by hand, and a demo of building and inspecting a JSON document. It spends time on syntax rules and structure rather than on any one programming language.

Why this video

This is the best fit for the 'What Is JSON?' subtopic and for understanding configuration files, since it grounds you in the format's rules before you start calling Python functions on it.

About These Videos

These videos were chosen from YouTube on October 2, 2026. Each has captions; the player turns them on. Videos on YouTube can be changed or removed — if one no longer plays, tell your instructor. If a player does not appear, use its Watch on YouTube link.