serialize_pydantic_serializable
No overview available.
def serialize_pydantic_serializable(
data: Union[BaseModel, List[BaseModel]]
) - > Union[Dict, List[Dict]]
Converts a Pydantic model or a list of Pydantic models into a JSON-serializable dictionary or list of dictionaries. This is used to prepare complex data structures for HTTP responses or storage by ensuring all nested Pydantic objects are flattened into primitive types.
Parameters
| Name | Type | Description |
|---|---|---|
| data | Union[BaseModel, List[BaseModel]] | The Pydantic model instance or list of model instances to be serialized. |
Returns
| Type | Description |
|---|---|
Union[Dict, List[Dict]] | A dictionary or a list of dictionaries containing the serialized data from the input Pydantic objects. |