This is a duplicate question because the following questions are either messy or they are not answered at all:
deserializing-a-generic-type-with-jackson
jack
public class AgentResponse {
private T result;
public AgentResponse(T result) {
this.result = result;
}
public T getResult() {
return result;
}
}
So for the above class structure and T can be of Type T1,T2 class
So to deserialize for AgentResponse, use the following code
JavaType javaType = objectMapper.getTypeFactory.constructParametricType(AgentResponse.class,T1.class)
AgentResponse agentResponseT1 = objectMapper.readValue(inputJson,javaType);