Skip to main content

SerializationInfo

Extra data used during serialization.

Attributes

AttributeTypeDescription
includeIncExCallThe include argument set during serialization.
excludeIncExCallThe exclude argument set during serialization.
contextContextTThe current serialization context.
mode`Literal['python', 'json']str`
by_aliasboolThe by_alias argument set during serialization.
exclude_unsetboolThe exclude_unset argument set during serialization.
exclude_defaultsboolThe exclude_defaults argument set during serialization.
exclude_noneboolThe exclude_none argument set during serialization.
exclude_computed_fieldsboolThe exclude_computed_fields argument set during serialization.
serialize_as_anyboolThe serialize_as_any argument set during serialization.
polymorphic_serialization`boolNone`
round_tripboolThe round_trip argument set during serialization.

Methods


include()

@classmethod
def include() - > IncExCall

The include argument set during serialization.

Returns

TypeDescription
IncExCallA set or mapping of fields to include in the serialized output

exclude()

@classmethod
def exclude() - > IncExCall

The exclude argument set during serialization.

Returns

TypeDescription
IncExCallA set or mapping of fields to exclude from the serialized output

context()

@classmethod
def context() - > ContextT

The current serialization context.

Returns

TypeDescription
ContextTThe user-defined context object shared across the serialization process

mode()

@classmethod
def mode() - > Literal['python', 'json']| str

The serialization mode set during serialization.

Returns

TypeDescription
`Literal['python', 'json']str`

by_alias()

@classmethod
def by_alias() - > bool

The by_alias argument set during serialization.

Returns

TypeDescription
boolWhether 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

TypeDescription
boolWhether 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

TypeDescription
boolWhether 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

TypeDescription
boolWhether 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

TypeDescription
boolWhether 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

TypeDescription
boolWhether 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

TypeDescription
`boolNone`

round_trip()

@classmethod
def round_trip() - > bool

The round_trip argument set during serialization.

Returns

TypeDescription
boolWhether 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

TypeDescription
boolTrue if the serialization mode is 'json', False otherwise