- Phase: 7. Modules, Stdlib & Testing
- Duration: 1.5 hours
- Understand the JSON format and its data type mappings
- Serialize Python objects to JSON with
json.dumpsandjson.dump - Deserialize JSON to Python objects with
json.loadsandjson.load - Pretty-print JSON output for readability
- Handle non-serializable custom objects using
defaultandcls
- JSON format overview and type mapping
json.dumps()— serialize to stringjson.dump()— serialize to filejson.loads()— parse from stringjson.load()— parse from file- Pretty-printing with
indentandsort_keys - Custom serialization via
defaultcallable andJSONEncodersubclass
Module 060: Milestone Project: Personal Expense Tracker
Module 062: Context Managers and the with Statement