Skip to content

Latest commit

 

History

History
30 lines (21 loc) · 911 Bytes

File metadata and controls

30 lines (21 loc) · 911 Bytes

Module 061: Working with JSON

  • Phase: 7. Modules, Stdlib & Testing
  • Duration: 1.5 hours

Learning Objectives

  • Understand the JSON format and its data type mappings
  • Serialize Python objects to JSON with json.dumps and json.dump
  • Deserialize JSON to Python objects with json.loads and json.load
  • Pretty-print JSON output for readability
  • Handle non-serializable custom objects using default and cls

Topics Covered

  • JSON format overview and type mapping
  • json.dumps() — serialize to string
  • json.dump() — serialize to file
  • json.loads() — parse from string
  • json.load() — parse from file
  • Pretty-printing with indent and sort_keys
  • Custom serialization via default callable and JSONEncoder subclass

Prerequisites

Module 060: Milestone Project: Personal Expense Tracker

Next Module

Module 062: Context Managers and the with Statement