Hey Roberto, I think that would be a great feature. Already had this case in the past and looks like Jackson and Gson already have it.
Gson subtypes on adapters. https://github.com/google/gson/blob/master/extras/src/main/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactory.java Jackson annotations with different strategies https://github.com/FasterXML/jackson-docs/wiki/JacksonPolymorphicDeserialization We should consider adding this feature I believe. Le mer. 18 avr. 2018 à 19:42, Roberto Cortez <[email protected]> a écrit : > Hi Romain, > Thanks for the quick response. > I'll have a look, > Cheers,Roberto > On Wednesday, April 18, 2018, 6:35:32 PM GMT+1, Romain Manni-Bucau < > [email protected]> wrote: > > Hi Roberto > > Yes, an adapter is the way to go using our mapper or jsonb. > > There should be an "animal" test showing how to do that. Just dont forget > to use class aliases or a whitelist logic to not open a backdoor. > > Since the model doesnt match the java model im not a fan of that feature > being built out of the box. In xml it is more natural but in json you can > do it without breaking the model. For me it means the model is broken and > must not be used as an input. > > Le 18 avr. 2018 19:31, "Roberto Cortez" <[email protected]> a > écrit : > > > Hi guys, > > I'm trying to serialize a list of elements of multiple types and then > > deserialize it again. It does require to somehow include the type in the > > serialization result to know to which type we should map to deserialize. > I > > think this could possible be done with an Adapter and playing with the > > JsonArray. > > I was just wondering if there any kind of out of the box support for > this. > > It doesn't seem so, at least I was not able to find. > > Jackson for instance, includes a set of annotations that allow you to do > > exactly this, without any extra / custom code. > > Any thoughts? > > Thank you. > > Cheers,Roberto
