xsdata.formats.dataclass.serializers.json module

xsdata.formats.dataclass.serializers.json.filter_none(x)[source]
Parameters

x (Tuple) –

Return type

Dict

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

Bases: object

Dictionary factory types.

FILTER_NONE()
Parameters

x (Tuple) –

Return type

Dict

class xsdata.formats.dataclass.serializers.json.JsonEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]

Bases: json.encoder.JSONEncoder

Custom Json encoder to support additional python build-in types.

default(obj)[source]

Override parent method to handle enumerations and decimals.

Parameters

obj (Any) –

Return type

Any

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

Bases: xsdata.formats.bindings.AbstractSerializer

Simple dictionary serializer with access to the dict factory.

Parameters

dict_factory (Callable) – Override default dict factory to add further logic.

dict_factory

alias of builtins.dict

render(obj)[source]

Convert the given object tree to dictionary with primitive values.

Parameters

obj (object) –

Return type

Dict

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

Bases: xsdata.formats.bindings.AbstractSerializer

Simple json.dumps wrapper.

Parameters
  • dict_factory (Callable) – Callable to generate dictionary.

  • encoder (Type[JSONEncoder]) – Value encoder.

  • indent (Optional[int]) – output indentation.

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.

Parameters

obj (object) –

Return type

str