xsdata.formats.dataclass.parsers module

class xsdata.formats.dataclass.parsers.JsonParser[source]

Bases: xsdata.formats.mixins.AbstractParser, xsdata.formats.dataclass.mixins.ModelInspect

parse(source, clazz)[source]

Parse the JSON input stream and return the resulting object tree.

Return type

Type

parse_context(data, model)[source]

Recursively build the given model from the input dict data.

Raises

TypeError – When parsing fails for any reason

Return type

Type

static parse_value(data, field)[source]

Find the field value in the given dictionary or return the default field value.

cache = None
class xsdata.formats.dataclass.parsers.XmlParser[source]

Bases: xsdata.formats.mixins.AbstractParser, xsdata.formats.dataclass.mixins.ModelInspect

parse(source, clazz)[source]

Parse the XML input stream and return the resulting object tree.

Return type

Type

parse_context(context, clazz)[source]

Build the given model from the iterparse event data.

Return type

Type

find_field(queue, namespace, element)[source]

Find the current field from the fields queue.

If the next field is also a dataclass append its fields map to the queue for the next event

Return type

Field

build_object_from_field(field, element)[source]

Bind the current element to a dataclass or simply parse its text value.

Return type

Type

build_object(clazz, element)[source]

Create a new class instance by the current element attributes and text.

Return type

Type

end_element(objects, queue, element)[source]

Finalize and return the last item of the objects list.

Steps:
  • Pop the last item of the objects

  • If the object is a dataclass pop the fields queue which should be the current object’s fields map

  • If the object is not the last in the list assign or append it to the correct parent field

Return type

Type

class_ns_fields(clazz, namespace)[source]

Returns the given class fields indexed by their namespace qualified names for easier match.

Return type

Dict[str, Field]

static parse_value(tp, value)[source]

Convert xml string values to python primite types.

Return type

Any

cache = None