dataclass-wizard
dataclass-wizard copied to clipboard
Question/feature request: Map a (nested) JSON/dict Key to a Field
It is possible to map JSON keys to fields with different names. However, I would like to map nested JSON/dict by key path, preferably by dot-delimited strings
'parent.child.grandchild[1].sibling'
or as lists of keys
['parent', 'child', 'grandchild', 1, 'sibling']
So it would look something like
class Meta(JSONSerializable.Meta):
json_key_to_field = {
'parent.child.grandchild[1].sibling': 'my_str'
}
or
json_field(
('myJSONKey',
'parent.child.grandchild[1].sibling',
('parent2', 'child', 'grandchild', 4, 'sibling'),
'myField'
)
As of yet, I have not been able to come up with a way to accomplish this with dataclass-wizard
. Do you know if this is currently possible? If not, is it something you would consider implementing?
Thank you for a terrific module btw!