orjson is a fast and correct Python JSON library supporting dataclasses, datetimes, and numpy. The current version is 3.11.7, released on March 28, 2026, with a release cadence of approximately every 3 months.
pip install orjsonVerified import paths — ran on the pinned version, not inferred.
A simple example demonstrating serialization and deserialization using orjson.
Ensure that all JSON input passed to orjson.loads() is encoded in UTF-8.
Ensure all objects passed to orjson.dumps() are serializable, or handle exceptions appropriately.
Provide a `default` callable function to `orjson.dumps()` that converts unsupported types into a serializable format (e.g., a dictionary, string, or list). For `Decimal` objects, convert them to `str` or `float`.
Ensure that the input data is strictly valid UTF-8. If reading from a file, open it in binary mode (`'rb'`) and pass the bytes directly to `orjson.loads()`. If decoding a string, verify its origin and encoding.
Replace unsupported keyword arguments with their corresponding `orjson.option` flags. For example, use `option=orjson.OPT_INDENT_2` for indentation and `option=orjson.OPT_SORT_KEYS` for sorting keys.
Explicitly decode the `bytes` output of `orjson.dumps()` to a `str` using `.decode('utf-8')` if a string is required by the consuming code. For example, `orjson.dumps(data).decode('utf-8')`.No dependency data recorded yet.