dict
xsdata.formats.dataclass.serializers.dict
DictFactory
Dictionary factory types.
Source code in xsdata/formats/dataclass/serializers/dict.py
25 26 27 28 | |
DictEncoder
dataclass
Json serializer for data classes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
SerializerConfig
|
The serializer config instance |
SerializerConfig()
|
context
|
XmlContext
|
The models context instance |
XmlContext()
|
dict_factory
|
Callable
|
Dictionary factory |
dict
|
Source code in xsdata/formats/dataclass/serializers/dict.py
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 98 99 100 101 102 103 104 105 106 107 108 109 | |
encode(value, var=None, wrapped=False)
Convert a value to a dictionary object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
The input value |
required |
var
|
XmlVar | None
|
The xml var instance |
None
|
wrapped
|
bool
|
Whether this is a wrapped value |
False
|
Returns:
| Type | Description |
|---|---|
Any
|
The converted json serializable value. |
Source code in xsdata/formats/dataclass/serializers/dict.py
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 | |
next_value(obj)
Fetch the next value of a model instance to convert.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The input model instance |
required |
Yields:
| Type | Description |
|---|---|
tuple[str, Any]
|
An iterator of field name and value tuples. |
Source code in xsdata/formats/dataclass/serializers/dict.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | |
filter_none(x)
Convert a key-value pairs to dict, ignoring None values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
tuple
|
Key-value pairs |
required |
Returns:
| Type | Description |
|---|---|
dict
|
The filtered dictionary. |
Source code in xsdata/formats/dataclass/serializers/dict.py
13 14 15 16 17 18 19 20 21 22 | |