File tree 3 files changed +24
-6
lines changed
main/java/com/fasterxml/jackson/databind
test/java/com/fasterxml/jackson/databind/node
3 files changed +24
-6
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ Project: jackson-databind
10
10
how is was deserialized first time
11
11
#785: Add handlings for classes which are available in `Thread.currentThread().getContextClassLoader()`
12
12
(contributed by Charles A)
13
+ #793: `ObjectMapper.readTree()` does not work with defaultTyping enabled
13
14
14
15
2.4.6 (23-Apr-2015)
15
16
Original file line number Diff line number Diff line change @@ -173,9 +173,12 @@ public boolean useForType(JavaType t)
173
173
}
174
174
// fall through
175
175
case OBJECT_AND_NON_CONCRETE :
176
- return (t .getRawClass () == Object .class ) || !t .isConcrete ()
177
- // [Issue#88] Should not apply to JSON tree models:
178
- || TreeNode .class .isAssignableFrom (t .getRawClass ());
176
+ // return t.isJavaLangObject() ||
177
+ return (t .getRawClass () == Object .class )
178
+ || (!t .isConcrete ()
179
+ // [databind#88] Should not apply to JSON tree models:
180
+ && !TreeNode .class .isAssignableFrom (t .getRawClass ()));
181
+
179
182
case NON_FINAL :
180
183
while (t .isArrayType ()) {
181
184
t = t .getContentType ();
@@ -184,6 +187,7 @@ public boolean useForType(JavaType t)
184
187
return !t .isFinal () && !TreeNode .class .isAssignableFrom (t .getRawClass ());
185
188
default :
186
189
//case JAVA_LANG_OBJECT:
190
+ // return t.isJavaLangObject();
187
191
return (t .getRawClass () == Object .class );
188
192
}
189
193
}
Original file line number Diff line number Diff line change @@ -85,8 +85,6 @@ public void testBinary() throws Exception
85
85
assertEquals ("\" Aw==\" " , n .toString ());
86
86
87
87
assertEquals ("AAMD" , new BinaryNode (data ).asText ());
88
-
89
- // 1.6:
90
88
assertNodeNumbersForNonNumeric (n );
91
89
}
92
90
@@ -101,10 +99,25 @@ public void testPOJO()
101
99
102
100
assertEquals (new POJONode (null ), new POJONode (null ));
103
101
104
- // 1.6:
105
102
// default; non-numeric
106
103
assertNodeNumbersForNonNumeric (n );
107
104
// but if wrapping actual number, use it
108
105
assertNodeNumbers (new POJONode (Integer .valueOf (123 )), 123 , 123.0 );
109
106
}
107
+
108
+ // [databind#793]
109
+ public void testArrayWithDefaultTyping () throws Exception
110
+ {
111
+ ObjectMapper mapper = new ObjectMapper ()
112
+ .enableDefaultTyping ();
113
+
114
+ JsonNode array = mapper .readTree ("[ 1, 2 ]" );
115
+ assertTrue (array .isArray ());
116
+ assertEquals (2 , array .size ());
117
+
118
+ JsonNode obj = mapper .readTree ("{ \" a\" : 2 }" );
119
+ assertTrue (obj .isObject ());
120
+ assertEquals (1 , obj .size ());
121
+ assertEquals (2 , obj .path ("a" ).asInt ());
122
+ }
110
123
}
You can’t perform that action at this time.
0 commit comments