read_json() reads a JSON file and deserializes it with Python's built-in json module.
read_json(
file_path: str | Path,
on_error: Literal["raise", "log", "silent"] | None = None,
) -> Any | Nonefrom clevertools import read_json
config = read_json("config.json", on_error="raise")
print(config["service"])from clevertools import read_json
payload = read_json("optional.json", on_error="silent") or {}
print(payload.get("enabled", False))- Invalid JSON returns
Noneunless the selected error mode raises. - Missing files and directory paths follow the shared error policy.
- The JSON root can be any valid JSON type, not only an object.