I'm not sure what you mean by "actual type definition". The specific code being used for writing would be the PersistentCollectionSerializer, which, from what I can gather, converts the value to be serialized into a java.util version and then sends that to an instance of CollectionSerializer. The ObjectMapper's encoding is set by jackson-security modules for spring security. There are no custom serializers or deserializers for this enum or the "ContainerType" object.
Tyler On Friday, July 9, 2021 at 5:13:08 PM UTC-5 Tatu Saloranta wrote: > On Fri, Jul 9, 2021 at 2:56 PM Tyler Williams > <[email protected]> wrote: > > > > "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? > > I think you are correct on most points, but to know for sure I'd need > to see the actual type definition (not description, definition), > as well as specific code being used for writing and reading. > > My guess is that there is a discrepancy between type information > available during reading and writing. > > -+ Tatu +- > -- 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/bfb5069a-9aba-4641-ac1e-5d3109735e1an%40googlegroups.com.
