Serializer
serialize_to_json(obj)
Serializes a dataclass object to a JSON string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj |
dataclass
|
A dataclass object to be serialized. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
A JSON string representing the serialized data from the dataclass object. |
Source code in libs/python/shared/py-serializer/pyserializer/serializer.py
serialize_to_dict(obj)
Serializes a dataclass object to a dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj |
dataclass
|
A dataclass object to be serialized. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Dict[str, any]
|
A dictionary containing the serialized data from the dataclass object. |
Source code in libs/python/shared/py-serializer/pyserializer/serializer.py
serialize_to_dataclass(data, cls)
Deserializes data from a dictionary into a dataclass object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data |
Dict[str, any]
|
A dictionary containing data to be deserialized. |
required |
cls |
Type
|
The dataclass type to which the data should be deserialized. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
cls |
dataclass
|
An instance of the specified dataclass type with data deserialized from the input dictionary. |