8 min read Beginner Lesson 9 of 11
Part 3 — Working with Data

JSON & Data Exchange

JavaScript Object Notation (JSON) is the undisputed lingua franca of the modern web. Python provides high-speed native serialization between JSON text strings and in-memory dictionaries.

The Dual Operations: `loads` vs `dumps`

1. Deserialization (`json.loads()`)

Converts a raw JSON text string into a Python Dictionary or List.

data = json.loads(raw_text)
2. Serialization (`json.dumps()`)

Converts a Python Dictionary into a valid JSON string (with indent formatting).

json_str = json.dumps(data, indent=2)

Quick Summary

  • JSON seamlessly maps to Python dictionaries, lists, booleans, and nulls (None).
  • Next, we model real-world domains with Object-Oriented Programming (OOP).