Json
The `json` module provides a simple API for encoding Python objects as JSON strings and decoding JSON data back into Python objects. The guide walks through Basic Serialization, File I/O, Custom Encoders, Pretty Printing, Advanced Usage. `json.dumps(obj)` converts a Python object to a JSON string. `json.loads(string)` parses JSON back to Python. Mapping: `dict` → object, `list` → array, `str` → string, `int`/`float` → number, `True`/`False` → boolean, `None` → null. `json.dump(obj, file)` writes JSON directly to a file object. `json.load(file)` reads JSON from a file. Both work with any file-like object, making it easy to combine with `open()` and context managers for safe file handling. Use the `cls` parameter with a custom `JSONEncoder` subclass to serialize types that JSON does not natively support (e.g., `datetime`, `Decimal`). Alternatively, pass a `default` function that converts unknown types to serializable ones. The guide is organized into 5 sections that build on each other, each pairing a prose explanation with runnable code.