xsdata.formats.dataclass.serializers package

Submodules

Module contents

class xsdata.formats.dataclass.serializers.DictFactory[source]

Bases: object

FILTER_NONE()
class xsdata.formats.dataclass.serializers.DictSerializer(dict_factory=<class 'dict'>)[source]

Bases: xsdata.formats.bindings.AbstractSerializer

dict_factory

alias of builtins.dict

render(obj)[source]

Convert the given object tree to dictionary with primitive values.

Return type

Dict

class xsdata.formats.dataclass.serializers.JsonSerializer(dict_factory=<class 'dict'>, encoder=<class 'xsdata.formats.dataclass.serializers.json.JsonEncoder'>, indent=None)[source]

Bases: xsdata.formats.bindings.AbstractSerializer

Variables
dict_factory

alias of builtins.dict

encoder

alias of JsonEncoder

indent: Optional[int] = None
render(obj)[source]

Convert the given object tree to json string.

Return type

str

class xsdata.formats.dataclass.serializers.XmlSerializer(name_generator=<function ModelInspect.<lambda>>, cache=<factory>, xml_declaration=True, encoding='UTF-8', pretty_print=False)[source]

Bases: xsdata.formats.bindings.AbstractSerializer, xsdata.formats.dataclass.mixins.ModelInspect

Variables
xml_declaration: bool = True
encoding: str = 'UTF-8'
pretty_print: bool = False
render(obj, namespaces=None)[source]

Convert the given object tree to xml string.

Optionally provide a namespaces instance with a predefined list of namespace uris and prefixes.

Return type

str

render_tree(obj, namespaces=None)[source]

Convert a dataclass instance to a nested Element structure.

Optionally provide a namespaces instance with a predefined list of namespace uris and prefixes.

Return type

Element

render_node(obj, parent, namespaces)[source]

Recursively traverse the given dataclass instance fields and build the lxml Element structure.

Return type

Element

render_sub_nodes(parent, values, var, namespaces)[source]
classmethod set_attribute(parent, key, value)[source]
classmethod set_attributes(parent, values)[source]
classmethod set_text(parent, value)[source]
classmethod set_tail(parent, value)[source]
classmethod set_nil_attribute(element, nillable, namespaces)[source]
classmethod next_value(meta, obj)[source]