The simplest way to debug things is usually to serialize Object in
question, then deserialize.
But before going into that, one thing you probably want to change is
the use of generic type as root value:
although it is supported and can be made to work, it is a well-known
source for issues. Life will be easier
if the root value is not generic (any type reference from there is fine).
Alternatively, if you absolutely do want additional challenge, you
will need to provide generic type BOTH for
serialization and deserialization: problem being Java Type Erasure
which will otherwise lose generic type
on serialization side.
Specifically, what you think of as `Cage<IAnimal>` can not be detected
as such, but only as `Cage<?>`, when
passing value. On deserialization it is less of a problem as you need
to provide type anyway.
On serialization, 2 main work-arounds (this is FAQ):
1. Create non-generic sub-type, use that (like `class AnimalCage
extend Cage<IAnimal> { .... }`)
2. Create `ObjectWriter` from mapper, with full type (TypeReference,
or JavaType):
mapper.writerFor(new TypeReference<Cage<IAnimal>>() {
}).writeValueAsBytes(cageValue);
Hope this helps,
-+ 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
jackson-user...@googlegroups.com.
> To post to this group, send email to
jackso...@googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.