data.dataclass_utils
DataClassFromDictMixin Objects
class DataClassFromDictMixin()
A mixin class that provides methods for converting dataclasses to/from dictionaries.
dict
def dict()
Convert the dataclass instance to a dictionary
from_dict
@classmethod
def from_dict(cls, data: Union[Dict, str])
Create a dataclass instance from a dictionary or JSON string.
Arguments:
data
- A dictionary or JSON string to convert to a dataclass instance.
Returns:
An instance of the dataclass.
Raises:
ValueError
- If the input string is not valid JSON.TypeError
- If the input is not a dictionary or JSON string.