_default
Converts various Python objects into a JSON-serializable format. It handles date objects by formatting them as HTTP dates, Decimal and UUID objects by converting them to strings, and dataclass instances by converting them to dictionaries. If an object has an __html__ method, it returns the string representation of its HTML. Otherwise, it raises a TypeError for non-serializable objects.
def _default(
o: t.Any
) - > t.Any
Serializes various Python objects into a JSON-compatible format. This function is used as a default encoder for types that are not natively JSON serializable, allowing them to be included in JSON output.
Parameters
| Name | Type | Description |
|---|---|---|
| o | t.Any | The object to be serialized into a JSON-compatible format. |
Returns
| Type | Description |
|---|---|
t.Any | A JSON-serializable representation of the input object. |