SerializationInfo
Extra data used during serialization.
Attributes
| Attribute | Type | Description |
|---|---|---|
| include | IncExCall | The include argument set during serialization. |
| exclude | IncExCall | The exclude argument set during serialization. |
| context | ContextT | The current serialization context. |
| mode | `Literal['python', 'json'] | str` |
| by_alias | bool | The by_alias argument set during serialization. |
| exclude_unset | bool | The exclude_unset argument set during serialization. |
| exclude_defaults | bool | The exclude_defaults argument set during serialization. |
| exclude_none | bool | The exclude_none argument set during serialization. |
| exclude_computed_fields | bool | The exclude_computed_fields argument set during serialization. |
| serialize_as_any | bool | The serialize_as_any argument set during serialization. |
| polymorphic_serialization | `bool | None` |
| round_trip | bool | The round_trip argument set during serialization. |
Methods
include()
@classmethod
def include() - > IncExCall
The include argument set during serialization.
Returns
| Type | Description |
|---|---|
IncExCall | A set or mapping of fields to include in the serialized output |
exclude()
@classmethod
def exclude() - > IncExCall
The exclude argument set during serialization.
Returns
| Type | Description |
|---|---|
IncExCall | A set or mapping of fields to exclude from the serialized output |
context()
@classmethod
def context() - > ContextT
The current serialization context.
Returns
| Type | Description |
|---|---|
ContextT | The user-defined context object shared across the serialization process |
mode()
@classmethod
def mode() - > Literal['python', 'json']| str
The serialization mode set during serialization.
Returns
| Type | Description |
|---|---|
| `Literal['python', 'json'] | str` |
by_alias()
@classmethod
def by_alias() - > bool
The by_alias argument set during serialization.
Returns
| Type | Description |
|---|---|
bool | Whether fields should be serialized using their defined aliases instead of their attribute names |
exclude_unset()
@classmethod
def exclude_unset() - > bool
The exclude_unset argument set during serialization.
Returns
| Type | Description |
|---|---|
bool | Whether fields that were not explicitly set during model initialization should be excluded |
exclude_defaults()
@classmethod
def exclude_defaults() - > bool
The exclude_defaults argument set during serialization.
Returns
| Type | Description |
|---|---|
bool | Whether fields equal to their default values should be excluded from the output |
exclude_none()
@classmethod
def exclude_none() - > bool
The exclude_none argument set during serialization.
Returns
| Type | Description |
|---|---|
bool | Whether fields with a value of None should be excluded from the output |
exclude_computed_fields()
@classmethod
def exclude_computed_fields() - > bool
The exclude_computed_fields argument set during serialization.
Returns
| Type | Description |
|---|---|
bool | Whether properties decorated with @computed_field should be excluded from the output |
serialize_as_any()
@classmethod
def serialize_as_any() - > bool
The serialize_as_any argument set during serialization.
Returns
| Type | Description |
|---|---|
bool | Whether to serialize using the actual runtime type of the object rather than the declared type |
polymorphic_serialization()
@classmethod
def polymorphic_serialization() - > bool | None
The polymorphic_serialization argument set during serialization, if any.
Returns
| Type | Description |
|---|---|
| `bool | None` |
round_trip()
@classmethod
def round_trip() - > bool
The round_trip argument set during serialization.
Returns
| Type | Description |
|---|---|
bool | Whether serialization is being performed in a way that supports full reconstruction of the object |
mode_is_json()
@classmethod
def mode_is_json() - > bool
Checks if the current serialization mode is set to JSON.
Returns
| Type | Description |
|---|---|
bool | True if the serialization mode is 'json', False otherwise |