You'll need to additionally override serializeWithType
within you CustomPetSerializer
because IPet
is polymorphic. That's also the reason why serialize
is not called. Check this related SO question that explains in detail when serializeWithType
is called. For instance, your serializeWithType
implementation might look something like this:
Read full article from java - JSON Jackson - exception when serializing a polymorphic class with custom serializer - Stack Overflow
No comments:
Post a Comment