Closed geohuk closed 3 years ago
Quick note: convertValue()
is quite likely to have issues with polymorphic typing: this combination is not meant to be used (although as of now, there is no checking to disallow such usage).
Does mapper.readValue()
works in this case?
Yes it does work fine with mapper.readValue(...)
. Interesting thanks!
Right: the problem wrt convertValue()
is that polymorphic typing requires strict type information as additional metadata -- but this typically means that structures of polymorphic-enabled and non-polymorphic values differ (are incompatible).
So if your input is in form of serialized JSON (or other supported formats) -- a byte[]
, InputStream
, String
etc -- you should be using readValue()
. "convertValue()" should only be used across Java types for which polymorphic handling is not enabled.
Describe the bug When using ObjectMapper to serialize and deserialize an object that contains JsonTypeInfo a MismatchedInputException is produced:
Version information 2.11.2
To Reproduce Here is my model:
JUnit test case that causes the exception:
Expected behavior Object serialized by ObjectMapper can be deserialized by ObjectMapper.