-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue handling unknown/unmapped Enum keys #1859
Comments
Hi, Could you please let me know when this fix could be available? Regards, |
@remya11 if and when someone has time and interest to work on this. |
Ok working on this. One quick note: if you declare map as Handling of "as default" is not working so I will try to fix that, but I will not change the way key handling works for simple Note that you could also consider custom |
So: handling |
Tried using the "READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE " with the JsonEnumDefaultValue annotation. It worked for the type Enum as expected. Then we have another issue where we are using a Map<Enum,String> object in our Bean class which didnot get resolved with above. When tried debugging, noticed the following code is going inside the class, EnumResolver since we a . It would be good if we can handle the same default value handling done in EnumDeserializer class , on this class as well so that we can use the default value we have defined. Appreciate a quick response.. Thank you. StdKeyDeserializer : |
As per comment on the new issue, note that you do need to use |
Thanks All... We went with a custom deserilizer and defaulting to a custom value and it resolved our issue. EnumMap also was not an option due to thrift model is not supporting any custom maps except map and tree map. |
isuribb, |
Hi,
Trying to deserialize a JSON string using jackson-databind Objectmapper which has a set of Enum attributes within it, but ends up in InvalidFormatException.
This happens when an unknown attribute, which is not defined in the enum comes in the JSON.
But, deserialization (objectMapper.readValue(jsonText, .class);) throws an error. "Test" is the unknown attribute that comes in the JSON String to be deserialized.
Sample of JSON String would look like this.
The JSON maps to a Cart class, which holds these attributes as a Map.
Attributes map to the Enum, as given below.
Also tried adding this configuration
This resulted in the Unknown attribute key to be deserialized as null. (i.e., instead of Test=No, it gets deserialized as null=No). So, when a new attribute - say, 'Test' comes in the Json, it would be good if the mapper can ignore that field and proceed with de-serializing the remaining fields that has a match in the Enum, rather than throwing the exception.
The text was updated successfully, but these errors were encountered: