On Mon, Jul 1, 2019 at 7:44 AM Avinash Vundyala
<[email protected]> wrote:
>
> My class Subtype structure looks like:
>
>        A
>       / \
>      B   C
>     /     \
>    D       E
>
> and using Jackson to deserialize JSON and when I mention defaultImpl to class 
> A then I get:
>
> Class A not subtype of [simple type, class B]
>
> can you please point out how to get the defaultImpl to work in case of 
> missing type id property

I'd need to know exact calls you are using (and probably
`@JsonTypeInfo` definitions); class hierarchy itself is not
sufficient.
And perhaps specific failure you get.

But one common problem is that users sometimes try to use a subtype as
target type on deserialization (like `B` or `C`) -- but `defaultImpl`
MUST be assignment compatible with given target type.
So it could be that you were trying something like:

  B result = mapper.readValue(source, B.class);

in which case you saying that base type of result value is `B`, and
therefore `A` would not be assignment-compatible default type.

-+ Tatu +-

-- 
You received this message because you are subscribed to the Google Groups 
"jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jackson-user/CAL4a10i55KNqryj7UOPQ1S5b3-XT3rpYqJr-vg%2B7MUxPR3giFg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to