You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have tried using specialized decoders for each field, so I can extract the portion of what I need. In this case, I want to avoid creating another dataclass to decode the field "myJsonField":
I ran into a similar problem. What I basically wound up realizing is that the structure of your dataclass has to mirror the structure of your serialized data. So you do have to make a nested dataclass. I wound up making variables like first and second here InitVar[str] and then wired them up to the nested dataclass in the __post_init__().
I have a use case in which a field in a JSON structure should be mapped into two separate fields in my dataclass:
I have tried using specialized decoders for each field, so I can extract the portion of what I need. In this case, I want to avoid creating another dataclass to decode the field "myJsonField":
The above does not work, as the second field overrides the first field.
What is the best way to tackle this case? Is there an alternative other than creating nested dataclasses?
The text was updated successfully, but these errors were encountered: