serializer
This module contains the Serializer
that is used to parse incoming network data into Python classes.
Serializer
Serializes wom.py model classes to and from raw bytes.
Source code in wom/serializer.py
decode
Decodes the data into the given model type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data |
bytes
|
The JSON payload as bytes. |
required |
model_type |
Type[T]
|
The type of model to decode into. |
required |
Returns:
| Type | Description |
|---|---|
T
|
The requested model. |
Source code in wom/serializer.py
encode
Encodes the object into JSON bytes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj |
Any
|
The object to encode. |
required |
Returns:
| Type | Description |
|---|---|
bytes
|
The encoded JSON payload. |
get_decoder
Lazily initializes decoders as they are requested and caches them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_type |
Type[T]
|
The model type this decoder will target. |
required |
Returns:
| Type | Description |
|---|---|
Decoder[T]
|
The requested decoder. |