Skip to main content
Loading page…
Python Mastery
Chapter 23
Lesson 1 of 3
JSON, Deeply
Contents
Notes
Tutor
Concept
Why JSON Serialization Gets Hard
Loading activity…
Previous
1 / 10
Continue
Contents
Notes
Discussion
Tutor
28 min
10 activities
0 of 10 done
In this lesson
1
Why JSON Serialization Gets Hard
2
Custom Encoder: datetime and Decimal
3
Dataclasses ↔ JSON: asdict and Custom from-dict
4
JSON Lines (NDJSON) for Streaming Large Data
5
Exercise: Round-Trip a Dataclass with Decimal
6
Gotcha: float vs Decimal Precision
7
object_hook Semantics
8
sort_keys, indent, separators, and Performance
9
JSON Formatting Options
10
Streaming Large JSON
Objectives
Serialize complex Python objects to JSON using custom JSONEncoder subclasses and the default= hook
Deserialize JSON back into rich Python types using object_hook
Round-trip dataclasses to and from JSON via dataclasses.asdict and a custom from-dict factory
Safely serialize datetime and Decimal values to and from JSON
Write and read JSON Lines (NDJSON) files for streaming large datasets
Learner understands sort_keys, indent, separators, and their performance implications
Chapter 23 · Serialization, Config & Data Interchange
JSON, Deeply
pickle & Its Dangers
Config: TOML, YAML, INI & .env
Previous: collections, math, random & more
Next: pickle & Its Dangers