json
xsdata.formats.dataclass.parsers.json
JsonParser
dataclass
Bases: DictDecoder
Json parser for data classes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config | ParserConfig | Parser configuration | ParserConfig() |
context | XmlContext | The models context instance | XmlContext() |
load_factory | Callable | Json loader factory | load |
Source code in xsdata/formats/dataclass/parsers/json.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
|
from_path(path, clazz=None)
Parse the input file into the target class type.
If no clazz is provided, the binding context will try to locate it from imported dataclasses.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path | Path | The path to the input file | required |
clazz | Optional[Type[T]] | The target class type to parse the file into | None |
Returns:
Type | Description |
---|---|
T | An instance of the specified class representing the parsed content. |
Source code in xsdata/formats/dataclass/parsers/json.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
|
from_string(source, clazz=None)
Parse the input source string into the target class type.
If no clazz is provided, the binding context will try to locate it from imported dataclasses.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source | str | The source string to parse | required |
clazz | Optional[Type[T]] | The target class type to parse the source string into | None |
Returns:
Type | Description |
---|---|
T | An instance of the specified class representing the parsed content. |
Source code in xsdata/formats/dataclass/parsers/json.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
|
from_bytes(source, clazz=None)
Parse the input source bytes object into the target class type.
If no clazz is provided, the binding context will try to locate it from imported dataclasses.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source | bytes | The source bytes object to parse | required |
clazz | Optional[Type[T]] | The target class type to parse the source bytes object | None |
Returns:
Type | Description |
---|---|
T | An instance of the specified class representing the parsed content. |
Source code in xsdata/formats/dataclass/parsers/json.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
|
parse(source, clazz=None)
Parse the input stream into the target class type.
If no clazz is provided, the binding context will try to locate it from imported dataclasses.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source | Any | The source file name or stream to parse | required |
clazz | Optional[Type[T]] | The target class type to parse the source object | None |
Returns:
Type | Description |
---|---|
T | An instance of the specified class representing the parsed content. |
Source code in xsdata/formats/dataclass/parsers/json.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
|
load_json(source)
Load the given json source filename or stream.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source | Any | A file name or file stream | required |
Returns:
Type | Description |
---|---|
Union[Dict, List] | The loaded dictionary or list of dictionaries. |
Source code in xsdata/formats/dataclass/parsers/json.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
|