konradhalas / dacite

Simple creation of data classes from dictionaries.
MIT License
1.72k stars 107 forks source link

can we map a key in dict to differently named member on a dataclass #115

Closed ramakrishnateja closed 3 years ago

ramakrishnateja commented 3 years ago

HI,

i have a case where assuming i have this dict

data = { "name": "test" }

@dataclass class X: full_name: str

would i be able to map name in the dict to full_name in the dataclass while converting dict to dataclass?

Thanks, Teja

konradhalas commented 3 years ago

@ramakrishnateja thank you for reporting this issue. Unfortunately this feature is out of scope of dacite library. We had something like that but we removed it. You can check reasoning here: https://github.com/konradhalas/dacite/issues/38