Skip to main content

SerField

This class represents a field configuration for serialization, mapping a specific key to its corresponding serializer and metadata. It manages field-level settings such as aliases, requirement status, and conditional exclusion logic to determine how data should be processed during the serialization phase.

Attributes

AttributeTypeDescription
keyPyBackedStrThe original attribute name on the Python object used as the source for serialization.
aliasOption< PyBackedStr >An alternative name used for the field in the serialized output instead of the original key.
serializerOption< Arc< CombinedSerializer > >The specific serialization logic applied to this field; if set to None, the field is excluded from output.
requiredboolA boolean flag indicating whether the field must be present during the serialization process.
serialize_by_aliasOption< bool >Determines whether to use the defined alias instead of the key when generating the serialized representation.
serialization_exclude_ifOption< Py< PyAny > >A Python callable or condition that determines if the field should be omitted from serialization based on its value.

Constructor

Signature

def SerField(
key: PyBackedStr,
alias: Option< PyBackedStr >,
serializer: Option< Arc< CombinedSerializer > >,
required: bool,
serialize_by_alias: Option< bool >,
serialization_exclude_if: Option< Py< PyAny > >
) - > null

Parameters

NameTypeDescription
keyPyBackedStrThe primary key name for the field.
aliasOption< PyBackedStr >An optional alternative name for the field during serialization.
serializerOption< Arc< CombinedSerializer > >The serializer to use for this field; if None, the field is excluded.
requiredboolIndicates if the field is mandatory.
serialize_by_aliasOption< bool >Determines if the alias should be used for serialization.
serialization_exclude_ifOption< Py< PyAny > >A condition or value that determines if the field should be excluded from serialization.

Signature

def SerField(
key: PyBackedStr,
alias: Option< PyBackedStr >,
serializer: Option< Arc< CombinedSerializer > >,
required: bool,
serialize_by_alias: Option< bool >,
serialization_exclude_if: Option< Py< PyAny > >
) - > null

Parameters

NameTypeDescription
keyPyBackedStrThe primary attribute name of the field as it exists on the Python object.
aliasOption< PyBackedStr >An alternative name used for the field during serialization, often for compatibility with external APIs.
serializerOption< Arc< CombinedSerializer > >The specific serialization logic to apply; if None, the field is excluded from the output.
requiredboolIndicates whether the field must be present during the serialization process.
serialize_by_aliasOption< bool >Determines if the alias should be used instead of the key when generating the serialized output.
serialization_exclude_ifOption< Py< PyAny > >A Python callable or condition used to dynamically determine if the field should be omitted from the output based on its value.