xsdata.formats.dataclass.parsers package¶
Submodules¶
Module contents¶
-
class
xsdata.formats.dataclass.parsers.
JsonParser
(name_generator=<function XmlContext.<lambda>>, cache=<factory>)[source]¶ Bases:
xsdata.formats.bindings.AbstractParser
,xsdata.formats.dataclass.context.XmlContext
-
parse
(source, clazz)[source]¶ Parse the JSON input stream and return the resulting object tree.
- Return type
~T
-
parse_context
(data, clazz)[source]¶ Recursively build the given model from the input dict data.
- Raises
TypeError – When parsing fails for any reason
- Return type
~T
-
bind_value
(var, value)[source]¶ Bind value according to the class var.
The return value can be: - a dataclass instance - a dictionary with unknown attributes - a list of unknown elements - an enumeration - a primitive value
- Return type
-
static
get_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
(index=<factory>, context=<factory>)[source]¶ Bases:
xsdata.formats.bindings.AbstractParser
-
index
: int = None¶
-
queue
: List[XmlNode] = None¶
-
namespaces
: Namespaces = None¶
-
objects
: List[Tuple[QName, Any]] = None¶
-
context
: XmlContext = None¶
-
parse
(source, clazz)[source]¶ Parse the XML input stream and return the resulting object tree.
- Return type
~T
-
parse_context
(context, clazz)[source]¶ Dispatch elements to handlers as they arrive and are fully parsed.
- Raises
ValueError – When the requested type doesn’t match the result object
- Return type
~T
-
queue_node
(element)[source]¶ Queue the next xml node for parsing based on the given element qualified name.
- Raises
ParserError – When the parser doesn’t know how to proceed.
-