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.
- Parameters
source (
BytesIO) –clazz (
Type[~T]) –
- 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
-
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(context=<factory>, event_names=<factory>, config=<factory>)[source]¶ Bases:
xsdata.formats.bindings.AbstractParser- Parameters
context (
XmlContext) –event_names (
Dict) –config (
ParserConfig) –
-
namespaces: Namespaces = None¶
-
context: XmlContext = None¶
-
event_names: Dict = None¶
-
config: ParserConfig = None¶
-
parse(source, clazz)[source]¶ Parse the XML input stream and return the resulting object tree.
- Parameters
source (
BytesIO) –clazz (
Type[~T]) –
- Return type
~T
-
parse_context(context, clazz)[source]¶ Dispatch elements to handlers as they arrive and are fully parsed.
- Raises
ParserError – When the requested type doesn’t match the result object
- Parameters
context (
iterparse) –clazz (
Type[~T]) –
- Return type
~T
-
add_namespace(namespace)[source]¶ Add the given namespace in the registry.
- Parameters
namespace (
Tuple) –
-
queue(element, queue, objects)[source]¶ Queue the next xml node for parsing based on the given element qualified name.