"testTypes": [
"java.util.HashSet",
[
[
"com.company.core.TestType",
"SCREENING_1"
],
[
"com.company.core.TestType",
"SCREENING_2"
],
[
"com.company.core.TestType",
"SCREENING_3"
]
]
],
The above is a serialized HashSet using the As.Property typing on the
ObjectMapper. I believe this is correct behavior because these enums are in
the Set and this is what As.Property does in this situation.
The problem I'm having is that the same ObjectMapper that wrote that JSON
can't deserialize it.
com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot
deserialize value of type `com.company.core.TestType` from String
"com.company.core.TestType": not one of the values accepted for Enum class:
[SCREENING_1, SCREENING_2, SCREENING_3]
at [Source:
(byte[])"["java.util.ArrayList",[{"@class":"com.company.ContainerType","id":1,"testTypes":["java.util.HashSet",[["company.core.TestType","SCREENING_1"],["company.core.TestType","SCREENING_2"],["company.core.TestType","SCREENING_3"]]],"shipDestinationTypes":["java.util.HashSet",[["com.company.mod"[truncated
19402 bytes]; line: 1, column: 229] (through reference chain:
java.util.ArrayList[0]->com.company.ContainerType["testTypes"]->java.util.HashSet[0])
com.fasterxml.jackson.databind.exc.InvalidFormatException.from(InvalidFormatException.java:67)
com.fasterxml.jackson.databind.DeserializationContext.weirdStringException(DeserializationContext.java:1851)
com.fasterxml.jackson.databind.DeserializationContext.handleWeirdStringValue(DeserializationContext.java:1079)
com.fasterxml.jackson.databind.deser.std.EnumDeserializer._deserializeAltString(EnumDeserializer.java:327)
com.fasterxml.jackson.databind.deser.std.EnumDeserializer._fromString(EnumDeserializer.java:214)
com.fasterxml.jackson.databind.deser.std.EnumDeserializer.deserialize(EnumDeserializer.java:188)
com.fasterxml.jackson.databind.deser.std.StdDeserializer._deserializeWrappedValue(StdDeserializer.java:368)
com.fasterxml.jackson.databind.deser.std.StdDeserializer._deserializeFromArray(StdDeserializer.java:215)
com.fasterxml.jackson.databind.deser.std.EnumDeserializer._deserializeOther(EnumDeserializer.java:337)
com.fasterxml.jackson.databind.deser.std.EnumDeserializer.deserialize(EnumDeserializer.java:201)
com.fasterxml.jackson.databind.deser.std.CollectionDeserializer._deserializeFromArray(CollectionDeserializer.java:347)
My guess from looking at this stuff through the debugger is that the
SimpleType of the enum doesn't create a typedeseriealizer and thus we just
deserialize the enum by calling EnumDeserializer.deserialize() instead of
EnumDeserializer.deserializeWithType(). Is there a configuration that I'm
missing?
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jackson-user/e64189a4-63f5-4185-a2d6-e9d1bd6d4df7n%40googlegroups.com.