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