Is there a way to perform serialization/deserialization in Jackson of polymorphic classes w/out using annotations or specialized bean fields? I have to support class hierarchies that I cannot modify and don’t wish to use annotations.
I’d like to be able to designate a synthetic name, which would not be in the classes that I am serializing/deserializing, that would be inserted into the JSON representation and used to identify the type.
If mix-ins are not to your liking, there isn’t anything pre-defined to pass, but you can relatively easily achieve this by sub-classing
JacksonAnnotationIntrospectorand configure mapper with it.In your implementation you can override all aspects of annotation access: in your case it’s probably enough to override
findTypeResolver()(and if you want per-property overrides, ‘findPropertyTypeResolver()’).The method can then use whatever mechanism you want to construct
TypeResolverBuilder(most likelyStdTypeResolverBuilder) that contains same information as what would usually come from@JsonTypeInfoannotation.