helpers
Miscellaneous helper functions.
dump(obj)
Dumps all pydantic models in an arbitrary object to dicts. As a side effect iterables are all downcast to lists. Useful when models exist in e.g. a list.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj |
Any
|
The object to dump. |
required |
Returns:
Type | Description |
---|---|
Any
|
tp.Any: The dumped object. |
Source code in watz/helpers.py
serialize(obj)
A wrapper on orjson.dumps()
to include all configuration options for handling all supported types.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj |
Any
|
The object to serialize to json. |
required |
Returns:
Name | Type | Description |
---|---|---|
bytes |
bytes
|
The serialized json bytes blob. |
Source code in watz/helpers.py
Last update:
October 19, 2023
Created: October 19, 2023
Created: October 19, 2023