0

Here is the case I am trying to solve

I get the class like this

ObjectMapper objectMapper = new ObjectMapper();
Class<?> cl = Class.forName(node.data());      

Now I fetch the data from the third party based on some criteria and trying to deserialize it like below

requestResponse = getFromThirdParty(requestResponse);
String data = requestResponse.getResponse().body();
objectMapper.readValue(data,cl[].class); ----> Here is the problem, compile time problem  

My problem is this statement, how do I fix the error at cl[].class?

In Jackson if it was a single JSON object, doing the below will work but how do I do it for an array of objects?

objectMapper.readValue(data,cl.class); 

Note: My class name is dynamic, it is known at runtime only.

voila
  • 1,594
  • 2
  • 19
  • 38

0 Answers0