deserialize based on value?
See original GitHub issueHi! I’m still playing with your amazing library. In continue of another question:
I’ve main dataclass:
@dataclass(slots=True)
class GameRequest(DataClassJSONMixin):
c: int
s: int
d: Any
o: str = None
t: int = None
I’ve many other classes for different c
value of main class and want to get them into d
value. I tried to use field(metadata={"deserialize": ... })
and define custom _deserialize
in SerializableType. But main problem is that i always get only dict, passed to d
and i don’t have any references to main class request.
using {'c': 1, 's': 2, 'o': 3, 't': 12345, 'd': {'zzz': 'aaa'}}
i always get only {'zzz': 'aaa'}
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Jackson deserialize based on type - Stack Overflow
} } } I am trying to avoid custom deserializer and attempting to deserialize the above JSON (called Wrapper. java) into Java POJOs....
Read more >Getting Started with Custom Deserialization in Jackson
This quick tutorial will illustrate how to use Jackson 2 to deserialize JSON using a custom Deserializer.
Read more >Deserialization of a polymorphic type based on presence of a ...
I'd like a feature on jackson for deserialization of polymorphic type ... based on the presence (or type or value) of an object's...
Read more >Best way to deserialize json objects based in property value ...
[Solved]-Best way to deserialize json objects based in property value-kotlin ... So when we convert the JSON string into the Event object, the...
Read more >Definitive Guide to Jackson ObjectMapper - Serialize and ...
In this detailed guide - learn everything you need to know about ObjectMapper. Convert JSON to and from Java POJOs, implement custom ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
If the choice of the ReqX class depends on another field of GameRequest, you can use the post_deserialize hook:
post_deserialize would be last thing on my mind Thanks! Worked.