@JsonAnySetter
assumes key of String
, does not consider declared type; should
#1035
Milestone
@JsonAnySetter
assumes key of String
, does not consider declared type; should
#1035
I previously was deserializing the following fields via JSON
But suddenly the Maps we were getting from this third party included some new fields, where both the keys and the values differed from what we were getting before.
We always get these new values, and want to keep them, so I moved over to use a new object that defines that new field plus @JsonAnySetter. Essentially I'm trying to create an object that acts like a HashMap<K, V> but has some known fields that I want to deserialize specially.
At first everything seemed to work. @JsonAnySetter figures out to deserialize my value as a Metrics object, and deserialization doesn't throw any exceptions. But jackson always passes a String into 'key'. Thanks to erasure, it happily accepts the wrong data, until I go to use it where I get class cast exceptions.
Unit Test
This test fails with
The text was updated successfully, but these errors were encountered: