5
5
6
6
import com .fasterxml .jackson .annotation .JsonInclude .Include ;
7
7
import com .fasterxml .jackson .core .JsonProcessingException ;
8
- import com .fasterxml .jackson .core .TreeNode ;
9
8
import com .fasterxml .jackson .databind .DeserializationFeature ;
9
+ import com .fasterxml .jackson .databind .JavaType ;
10
10
import com .fasterxml .jackson .databind .JsonMappingException ;
11
11
import com .fasterxml .jackson .databind .JsonNode ;
12
12
import com .fasterxml .jackson .databind .ObjectMapper ;
13
13
import com .fasterxml .jackson .databind .SerializationFeature ;
14
14
import com .fasterxml .jackson .databind .annotation .JsonPOJOBuilder ;
15
15
import com .fasterxml .jackson .databind .introspect .AnnotatedClass ;
16
16
import com .fasterxml .jackson .databind .introspect .JacksonAnnotationIntrospector ;
17
+ import com .fasterxml .jackson .databind .type .TypeFactory ;
17
18
import com .fasterxml .jackson .datatype .jsr310 .JavaTimeModule ;
18
19
19
20
import lombok .AccessLevel ;
@@ -59,6 +60,10 @@ public JsonPOJOBuilder.Value findPOJOBuilderConfig(final AnnotatedClass ac) {
59
60
return s ;
60
61
}
61
62
63
+ public TypeFactory getTypeFactory () {
64
+ return objectMapper .getTypeFactory ();
65
+ }
66
+
62
67
public <T > String toStringFrom (final T sourceObject ) {
63
68
try {
64
69
return objectMapper .writeValueAsString (sourceObject );
@@ -77,9 +82,9 @@ public <T> T fromStringTo(final Class<T> targetClass, final String sourceJson) {
77
82
}
78
83
}
79
84
80
- public <T > T fromTreeTo (final Class < T > targetClass , final TreeNode treeNode ) {
85
+ public <T > T fromStringTo (final JavaType targetClass , final String sourceJson ) {
81
86
try {
82
- return objectMapper .treeToValue ( treeNode , targetClass );
87
+ return objectMapper .readValue ( sourceJson , targetClass );
83
88
} catch (JsonMappingException e ) {
84
89
throw new info .unterrainer .commons .serialization .exceptions .JsonMappingException (e .getMessage (), e );
85
90
} catch (JsonProcessingException e ) {
0 commit comments