Last active
February 21, 2019 05:40
-
-
Save codethereforam/b87ce441108748fd5c4f3ecec944a564 to your computer and use it in GitHub Desktop.
jackson deserialization json to generic java object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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