04.03

Serialisation and JSON Schema

skillmaxingPython with AISerialisation and JSON Schema
Visual lesson

Serialisation and JSON Schema

Included with Pro · 4:43
Lessons · 1,002 words

Validation is the trip into a model. Serialisation is the trip back out: turning a Ticket with a datetime and a nested Customer into something a browser, a queue, or a language model can read. Pydantic gives you exact control over that trip, and the same model can also describe itself as a JSON Schema, so the shape you validate against is the shape you publish to clients and to tools.

The distinction to keep in mind is between a Python dump and a JSON dump. A Python dump keeps datetime and Decimal objects as they are, which is what you want when passing data between functions. A JSON dump turns them into strings and numbers that survive json.dumps, which is what you want at the edge.

Pro

Continue reading

Pro unlocks every video lesson, the full notes and runnable code across the Python with AI course, from the language itself to agents, MCP, Langfuse and deployment.

Unlock full access to
Python with AIAI researchComplete system design
30% off with LAUNCH30ends in 7h 40m
Buy now
View all plans ·Already Pro? Sign in
124 online