Skip to content

Instantly share code, notes, and snippets.

@mressler
Created July 8, 2014 18:07
Show Gist options
  • Save mressler/a2c082f75deb04ac367f to your computer and use it in GitHub Desktop.
Save mressler/a2c082f75deb04ac367f to your computer and use it in GitHub Desktop.
Type Erasure and Deserializing JSON Objects
public static class ProfileResponse extends ODataListValueDTO<UserProfileDTO> {}
// I was having a lot of difficulty getting Jackson to appropriately deserialize a complex
// data type due to type erasure. By creating an "as needed" class, I can avoid the type
// erasure problem and get an ODataListValueDTO<UserProfileDTO> as a result
ResponseEntity<ProfileResponse> profileResponse = template.exchange(
"http://localhost:8080/dummy",
HttpMethod.POST,
new HttpEntity<UserProfileDTO>(toSend, headers),
ProfileResponse.class);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment