Skip to content

Commit e937f40

Browse files
authored
Merge pull request aol#368 from aol/davidartplus-jacksonutil
Implementation for convertFromJson with TypeReference
2 parents 6eed200 + c323bae commit e937f40

File tree

1 file changed

+10
-0
lines changed
  • micro-jackson-configuration/src/main/java/com/aol/micro/server/rest/jackson

1 file changed

+10
-0
lines changed

micro-jackson-configuration/src/main/java/com/aol/micro/server/rest/jackson/JacksonUtil.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import com.fasterxml.jackson.annotation.JsonInclude.Include;
1616
import com.fasterxml.jackson.databind.JavaType;
1717
import com.fasterxml.jackson.databind.ObjectMapper;
18+
import com.fasterxml.jackson.core.type.TypeReference;
1819

1920
public final class JacksonUtil {
2021

@@ -94,6 +95,15 @@ public static <T> T convertFromJson(final String jsonString, final JavaType type
9495
return null;
9596

9697
}
98+
99+
public static <T> T convertFromJson(String json, final TypeReference<T> type) {
100+
try {
101+
return JacksonUtil.getMapper().readValue(json, type);
102+
} catch (final Exception ex) {
103+
ExceptionSoftener.throwSoftenedException(ex);
104+
}
105+
return null;
106+
}
97107

98108
public static Object serializeToJsonLogFailure(Object value) {
99109
try {

0 commit comments

Comments
 (0)