_default
Converts various Python objects into JSON-serializable formats, specifically handling dates as HTTP dates, Decimals and UUIDs as strings, dataclasses as dictionaries, and objects with an html method as strings.
def _default(
o: t.Any
) - > t.Any
Provides a fallback serialization mechanism for objects not natively supported by the standard JSON encoder. It converts dates to HTTP-formatted strings, decimals and UUIDs to plain strings, dataclasses to dictionaries, and HTML-capable objects to their string representation.
Parameters
| Name | Type | Description |
|---|---|---|
| o | t.Any | The object instance to be serialized into a JSON-compatible format. |
Returns
| Type | Description |
|---|---|
t.Any | A JSON-serializable representation of the input object, such as a string or a dictionary. |