I am trying to consume an API whose response is like:-
{
"data": [
[
"2075/76",
"2075-2094767",
"2075/08/29",
1466,
"210003502",
null,
"गीता श्रीस काउचा थापा",
2418146,
null,
14224,
"Production",
1800,
0,
"2074/75",
"2075/09/02",
"Cash",
null,
"1",
null,
null,
11019,
"2018/12/17",
0,
"T",
null,
"2018/12/17"
],
[
"2075/76",
"2075-2093892",
"2075/08/28",
1466,
"210003502",
null,
"हेमन्त बुढाथोकी",
2417027,
null,
14224,
"Production",
1400,
0,
"2074/75",
"2075/09/02",
"Cash",
null,
"1",
null,
null,
11019,
"2018/12/17",
0,
"T",
null,
"2018/12/17"
]
]
}
I am using spring boot and rest template like this.
@GetMapping("/consume")
public void consumeApi(@RequestParam String date) throws IOException {
BankVoucherParams params = setVoucherParams(date);
RestTemplate restTemplate = new RestTemplate();
String token = getBearerToken();
HttpHeaders headers = new HttpHeaders();
headers.setBearerAuth(token);
HttpEntity<BankVoucherParams> request = new HttpEntity<BankVoucherParams>(params, headers);
String response = restTemplate.postForObject(endpoint, request, String.class);
ObjectMapper objectMapper = new ObjectMapper();
Object o = objectMapper.readValue(response,Object.class);
System.out.println(response);
}
in the above code I get the response in string form. I want to map every value to a pojo class and insert it into my database. For now I don't know how to map each of these array into my pojo class.