File tree 2 files changed +22
-7
lines changed
main/java/com/fasterxml/jackson/databind
test/java/com/fasterxml/jackson/databind/node
2 files changed +22
-7
lines changed Original file line number Diff line number Diff line change @@ -173,9 +173,11 @@ 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
+ || (!t .isConcrete ()
178
+ // [databind#88] Should not apply to JSON tree models:
179
+ && !TreeNode .class .isAssignableFrom (t .getRawClass ()));
180
+
179
181
case NON_FINAL :
180
182
while (t .isArrayType ()) {
181
183
t = t .getContentType ();
@@ -184,7 +186,7 @@ public boolean useForType(JavaType t)
184
186
return !t .isFinal () && !TreeNode .class .isAssignableFrom (t .getRawClass ());
185
187
default :
186
188
//case JAVA_LANG_OBJECT:
187
- return ( t . getRawClass () == Object . class );
189
+ return t . isJavaLangObject ( );
188
190
}
189
191
}
190
192
}
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