I posted this question incorrectly. I posted the question correctly here ...
I get a json string as an HTTP response. I know its structure. It looks like this:
public class Json<T> { public Hits<T> hits; } public class Hits<T> { public int found; public int start; public ArrayList<Hit<T>> hit; } public class Hit<T> { public String id; public Class<T> data; }
The data field can belong to any class. I will only know this at runtime. I will get it as a parameter. This is how I deserialize.
public <T> void deSerialize(Class<T> clazz { ObjectMapper mapper = new ObjectMapper(); mapper.readValue(jsonString, new TypeReference<Json<T>>() {}); }
But I get an error -
cannot access private java.lang.class.Class () from java.lang.class. Failed to establish access. Cannot make java.lang.Class constructor available
java json generics jackson
gnjago Jul 25 2018-12-25T00: 00Z
source share