Serialization and JSON
- id: 1749653457
- Date: June 11, 2025, 2:54 p.m.
- Author: Donald F. Elger
Goals
- Describe serialization.
- Explain how to serialize and deserialize using python and JSON.
Serialization and Deserialization
Serialization is the process of converting a data structure (like a Python object) into a format that can be stored or transmitted, such as a string, file, or stream.
Deserialization is the reverse — converting that format back into a usable data structure.
S:D in Python
Term | Function | Direction |
---|---|---|
Serialization | json.dumps() |
Python → JSON string |
Deserialization | json.loads() |
JSON string → Python |
S:D in Django
If your Django model field is a JSONField, there is no need to manually serialize or deserialize your data structure because Django does this automatically for you.