Skip to content

Instantly share code, notes, and snippets.

@codethereforam
Last active February 21, 2019 05:40
Show Gist options
  • Save codethereforam/b87ce441108748fd5c4f3ecec944a564 to your computer and use it in GitHub Desktop.
Save codethereforam/b87ce441108748fd5c4f3ecec944a564 to your computer and use it in GitHub Desktop.
jackson deserialization json to generic java object
/**
* jackson deserialization json to generic java object
*
* @param jsonStr json string
* @param typeReference typeReference
* @return generic object
* @author yanganyu
* @date 2019/2/21 13:37
*/
public static <T> T parse(String jsonStr, TypeReference<T> typeReference) {
T result = null;
try {
result = new ObjectMapper().readValue(jsonStr, typeReference);
} catch (IOException e) {
e.printStackTrace();
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment