|
7 | 7 |
|
8 | 8 | import com.fasterxml.jackson.core.*;
|
9 | 9 |
|
10 |
| -import com.fasterxml.jackson.databind.DeserializationContext; |
11 |
| -import com.fasterxml.jackson.databind.JsonNode; |
12 |
| -import com.fasterxml.jackson.databind.ObjectMapper; |
| 10 | +import com.fasterxml.jackson.databind.*; |
13 | 11 | import com.fasterxml.jackson.databind.ObjectMapper.DefaultTyping;
|
14 | 12 | import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
|
15 | 13 | import com.fasterxml.jackson.databind.deser.std.StdScalarDeserializer;
|
|
20 | 18 | * one that only uses core JDK types; wrappers, Maps and Lists.
|
21 | 19 | */
|
22 | 20 | public class TestUntypedDeserialization
|
23 |
| - extends com.fasterxml.jackson.test.BaseTest |
| 21 | + extends BaseMapTest |
24 | 22 | {
|
25 | 23 | @SuppressWarnings("serial")
|
26 | 24 | static class UCStringDeserializer
|
@@ -151,6 +149,22 @@ public void testSampleDoc() throws Exception
|
151 | 149 | // and that's all folks!
|
152 | 150 | }
|
153 | 151 |
|
| 152 | + public void testNestedUntypes() throws IOException |
| 153 | + { |
| 154 | + ObjectMapper mapper = objectMapper(); |
| 155 | + Object root = mapper.readValue(aposToQuotes("{'a':3,'b':[1,2]}"), |
| 156 | + Object.class); |
| 157 | + assertTrue(root instanceof Map<?,?>); |
| 158 | + Map<?,?> map = (Map<?,?>) root; |
| 159 | + assertEquals(2, map.size()); |
| 160 | + assertEquals(Integer.valueOf(3), map.get("a")); |
| 161 | + Object ob = map.get("b"); |
| 162 | + assertTrue(ob instanceof List<?>); |
| 163 | + List<?> l = (List<?>) ob; |
| 164 | + assertEquals(2, l.size()); |
| 165 | + assertEquals(Integer.valueOf(2), l.get(1)); |
| 166 | + } |
| 167 | + |
154 | 168 | // [JACKSON-839]: allow 'upgrade' of big integers into Long, BigInteger
|
155 | 169 | public void testObjectSerializeWithLong() throws IOException
|
156 | 170 | {
|
|
0 commit comments