I am working on a spring boot app where I am getting pageable response and then I want to take that pageable response array to parse it to a list of some DTO.
Here's my function:
public Object fetchSkuGroupsByIdAndWarehouseId(Integer warehouseId, Integer pageNumber, Integer pageSize,
Long groupId) throws IOException, NoSuchFieldException, IllegalAccessException {
ResponseEntity<FeignClientResponse> responseEntity = locationInventoryClient.fetchGroupsByIdAndWarehouseId(warehouseId,pageNumber,pageSize,groupId);
PageableResponse response;
try {
response= objectMapper.readValue(objectMapper.writeValueAsString(
responseEntity.getBody().getData()), PageableResponse.class);
} catch (JsonProcessingException e){
log.error("JsonProcessingException in method fetchSkuGroupsByIdIn");
throw new InvalidMovementRequest("JsonProcessingException in method fetchSkuGroupsByIdIn");
}
log.info(response.getData().toString());
List<Object> list= (List<Object>) response.getData();
//have to convert here to List<SkuGroupDTO>.
return "hey";
}
I am also getting the List list correctly but not able to parse it to a existing DTO that I have,I tried map and streams but no success.
Any ways that I can do it?