Skip to content

Instantly share code, notes, and snippets.

@sunieldalal
Created December 5, 2016 19:21
Show Gist options
  • Select an option

  • Save sunieldalal/a9c821a70db1cb51baaaeaee23acd281 to your computer and use it in GitHub Desktop.

Select an option

Save sunieldalal/a9c821a70db1cb51baaaeaee23acd281 to your computer and use it in GitHub Desktop.
/**
* Serialize the response into the DTO POJO.
* Assumption: Jackson Jar is in classpath
* @param strResponse
* @return
*/
protected EmployeeDto convertResponseJsonToPojo(String strResponse) {
ObjectMapper mapper = new ObjectMapper();
// Don't fail on unknown properties
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
EmployeeDto responseDto = null;
try {
responseDto = mapper.readValue(strResponse, EmployeeDto.class);
} catch (Exception e) {
throw new RuntimeException("Cannot parse response from string: " + strResponse);
}
return responseDto;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment