Hello! I'd like to deserialize a java class:
class A.
I want to use @JsonDeserialize(using AFactory.class).
I also have a class B extends A.
In AFactory I'd like to provide the deserialize(JsonParser jp, DeserializationContext ctxt) method.
I want it to do some pre-processing (why I don't use @JsonTypeInfo) and then return an instance of B (or whichever class that extends A I choose).
When I at the end do
JsonNode node = jp.getCodec().readTree(jp);
String clazzNode = node.get("class").asText();
clazz = (Class<? extends Topological>) Class.forName(clazzname); //This is B.
return (Topological) jacksonMapper.treeToValue(node, clazz);
I get an infinite loop because the jacksonMapper.treeToValue() tries to re-run the same pre-processor, even though I told it to do clazz, which is B, not A!
How should I do this correctly?