1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.juneau;
18
19 import static org.apache.juneau.TestUtils.*;
20 import static org.junit.jupiter.api.Assertions.*;
21
22 import java.util.*;
23
24 import org.apache.juneau.collections.*;
25 import org.apache.juneau.objecttools.*;
26 import org.junit.jupiter.api.*;
27
28 class JsonMap_Test extends TestBase {
29
30
31
32
33 @Test void a01_basic() throws Exception {
34 var in = "{A:'asdf'}";
35
36 checkStep(1, in, JsonMap.ofJson(in).getString("A"), "asdf");
37
38 in = "{A:{B:'asdf'}}";
39 checkStep(2, in, getDeepString(JsonMap.ofJson(in), "A/B"), "asdf");
40 checkStep(3, in, JsonMap.ofJson(in).getString("A"), "{B:'asdf'}");
41
42 in = "{A:{B:'asdf'+\"asdf\"}}";
43 checkStep(4, in, getDeepString(JsonMap.ofJson(in), "A/B"), "asdfasdf");
44 checkStep(5, in, JsonMap.ofJson(in).getString("A"), "{B:'asdfasdf'}");
45
46 in = "{A:{B:'asdf' + \n\t \"asdf\"}}";
47 checkStep(6, in, getDeepString(JsonMap.ofJson(in), "A/B"), "asdfasdf");
48 checkStep(7, in, JsonMap.ofJson(in).getString("A"), "{B:'asdfasdf'}");
49
50 in = "{A:{B:'asdf\"asdf', C:\"asdf'asdf\", D : \"asdf\\\"asdf\", E: 'asdf\\\'asdf', F:\"asdf\\\'asdf\", G:'asdf\\\"asdf'}}";
51 checkStep(8, in, getDeepString(JsonMap.ofJson(in), "A/B"), "asdf\"asdf");
52 checkStep(9, in, getDeepString(JsonMap.ofJson(in), "A/C"), "asdf'asdf");
53 checkStep(10, in, getDeepString(JsonMap.ofJson(in), "A/D"), "asdf\"asdf");
54 checkStep(11, in, getDeepString(JsonMap.ofJson(in), "A/E"), "asdf'asdf");
55 checkStep(12, in, getDeepString(JsonMap.ofJson(in), "A/F"), "asdf'asdf");
56 checkStep(13, in, getDeepString(JsonMap.ofJson(in), "A/G"), "asdf\"asdf");
57
58 in = "{A:123, B: 123}";
59 checkStep(16, in, JsonMap.ofJson(in).getInt("A").toString(), "123");
60 checkStep(17, in, JsonMap.ofJson(in).getInt("B").toString(), "123");
61
62 in = "{A:true, B: true, C:false, D: false}";
63 checkStep(18, in, JsonMap.ofJson(in).getBoolean("A").toString(), "true");
64 checkStep(19, in, JsonMap.ofJson(in).getBoolean("B").toString(), "true");
65 checkStep(20, in, JsonMap.ofJson(in).getBoolean("C").toString(), "false");
66 checkStep(21, in, JsonMap.ofJson(in).getBoolean("D").toString(), "false");
67
68 in = "{'AAA':{\"BBB\":\"CCC\",'DDD':false}}";
69 checkStep(31, in, getDeepString(JsonMap.ofJson(in), "AAA/BBB"), "CCC");
70 checkStep(32, in, getDeepBoolean(JsonMap.ofJson(in), "AAA/DDD").toString(), "false");
71
72 in = " \n\n\t { 'AAA' : { \"BBB\" : \"CCC\" , 'DDD' : false } } \n\t";
73 checkStep(33, in, getDeepString(JsonMap.ofJson(in), "AAA/BBB"), "CCC");
74 checkStep(34, in, getDeepBoolean(JsonMap.ofJson(in), "AAA/DDD").toString(), "false");
75
76 in = "/*x*/{A:'B','C':1,\"E\":[1,2,3],G:['g1','g2','g3']}";
77 checkStep(100, in, JsonMap.ofJson(in).getString("A"), "B");
78 in = "{/*x*/A:'B','C':1,\"E\":[1,2,3],G:['g1','g2','g3']}";
79 checkStep(101, in, JsonMap.ofJson(in).getString("A"), "B");
80 in = "{A/*x*/:'B','C':1,\"E\":[1,2,3],G:['g1','g2','g3']}";
81 checkStep(102, in, JsonMap.ofJson(in).getString("A"), "B");
82 in = "{A:/*x*/'B','C':1,\"E\":[1,2,3],G:['g1','g2','g3']}";
83 checkStep(103, in, JsonMap.ofJson(in).getString("A"), "B");
84 in = "{A:'/*x*/B','C':1,\"E\":[1,2,3],G:['g1','g2','g3']}";
85 checkStep(104, in, JsonMap.ofJson(in).getString("A"), "/*x*/B");
86 in = "{A:'B/*x*/','C':1,\"E\":[1,2,3],G:['g1','g2','g3']}";
87 checkStep(105, in, JsonMap.ofJson(in).getString("A"), "B/*x*/");
88 in = "{A:'B'/*x*/,'C':1,\"E\":[1,2,3],G:['g1','g2','g3']}";
89 checkStep(106, in, JsonMap.ofJson(in).getString("A"), "B");
90 in = "{A:'B',/*x*/'C':1,\"E\":[1,2,3],G:['g1','g2','g3']}";
91 checkStep(107, in, JsonMap.ofJson(in).getString("C"), "1");
92 in = "{A:'B','C':/*x*/1,\"E\":[1,2,3],G:['g1','g2','g3']}";
93 checkStep(108, in, JsonMap.ofJson(in).getString("C"), "1");
94 in = "{A:'B','C':1/*x*/,\"E\":[1,2,3],G:['g1','g2','g3']}";
95 checkStep(109, in, JsonMap.ofJson(in).getString("C"), "1");
96 in = "{A:'B','C':1,/*x*/\"E\":[1,2,3],G:['g1','g2','g3']}";
97 checkStep(110, in, JsonMap.ofJson(in).getList("E").getString(0), "1");
98 in = "{A:'B','C':1,\"/*x*/E\":[1,2,3],G:['g1','g2','g3']}";
99 checkStep(111, in, JsonMap.ofJson(in).getList("/*x*/E").getString(0), "1");
100 in = "{A:'B','C':1,\"E/*x*/\":[1,2,3],G:['g1','g2','g3']}";
101 checkStep(112, in, JsonMap.ofJson(in).getList("E/*x*/").getString(0), "1");
102 in = "{A:'B','C':1,\"E\"/*x*/:[1,2,3],G:['g1','g2','g3']}";
103 checkStep(113, in, JsonMap.ofJson(in).getList("E").getString(0), "1");
104 in = "{A:'B','C':1,\"E\":/*x*/[1,2,3],G:['g1','g2','g3']}";
105 checkStep(114, in, JsonMap.ofJson(in).getList("E").getString(0), "1");
106 in = "{A:'B','C':1,\"E\":[/*x*/1,2,3],G:['g1','g2','g3']}";
107 checkStep(115, in, JsonMap.ofJson(in).getList("E").getString(0), "1");
108 in = "{A:'B','C':1,\"E\":[1/*x*/,2,3],G:['g1','g2','g3']}";
109 checkStep(116, in, JsonMap.ofJson(in).getList("E").getString(0), "1");
110 in = "{A:'B','C':1,\"E\":[1,/*x*/2,3],G:['g1','g2','g3']}";
111 checkStep(117, in, JsonMap.ofJson(in).getList("E").getString(1), "2");
112 in = "{A:'B','C':1,\"E\":[1,2/*x*/,3],G:['g1','g2','g3']}";
113 checkStep(118, in, JsonMap.ofJson(in).getList("E").getString(1), "2");
114 in = "{A:'B','C':1,\"E\":[1,2,/*x*/3],G:['g1','g2','g3']}";
115 checkStep(119, in, JsonMap.ofJson(in).getList("E").getString(2), "3");
116 in = "{A:'B','C':1,\"E\":[1,2,3]/*x*/,G:['g1','g2','g3']}";
117 checkStep(120, in, JsonMap.ofJson(in).getList("E").getString(2), "3");
118 in = "{A:'B','C':1,\"E\":[1,2,3],/*x*/G:['g1','g2','g3']}";
119 checkStep(121, in, JsonMap.ofJson(in).getList("G").getString(0), "g1");
120 in = "{A:'B','C':1,\"E\":[1,2,3],G:[/*x*/'g1','g2','g3']}";
121 checkStep(122, in, JsonMap.ofJson(in).getList("G").getString(0), "g1");
122 in = "{A:'B','C':1,\"E\":[1,2,3],G:['/*x*/g1','g2','g3']}";
123 checkStep(123, in, JsonMap.ofJson(in).getList("G").getString(0), "/*x*/g1");
124 in = "{A:'B','C':1,\"E\":[1,2,3],G:['g1'/*x*/,'g2','g3']}";
125 checkStep(124, in, JsonMap.ofJson(in).getList("G").getString(0), "g1");
126 in = "{A:'B','C':1,\"E\":[1,2,3],G:['g1',/*x*/'g2','g3']}";
127 checkStep(125, in, JsonMap.ofJson(in).getList("G").getString(1), "g2");
128 in = "{A:'B','C':1,\"E\":[1,2,3],G:['g1','g2'/*x*/,'g3']}";
129 checkStep(126, in, JsonMap.ofJson(in).getList("G").getString(1), "g2");
130 in = "{A:'B','C':1,\"E\":[1,2,3],G:['g1','g2',/*x*/'g3']}";
131 checkStep(127, in, JsonMap.ofJson(in).getList("G").getString(2), "g3");
132 in = "{A:'B','C':1,\"E\":[1,2,3],G:['g1','g2','g3'/*x*/]}";
133 checkStep(128, in, JsonMap.ofJson(in).getList("G").getString(2), "g3");
134 in = "{A:'B','C':1,\"E\":[1,2,3],G:['g1','g2','g3']/*x*/}";
135 checkStep(129, in, JsonMap.ofJson(in).getList("G").getString(2), "g3");
136 in = "{A:'B','C':1,\"E\":[1,2,3],G:['g1','g2','g3']}/*x*/";
137 checkStep(130, in, JsonMap.ofJson(in).getList("G").getString(2), "g3");
138
139 in = "/*\tx\t*///\tx\t\n\t/*\tx\t*/{A:'B','C':1,\"E\":[1,2,3],G:['g1','g2','g3']}";
140 checkStep(201, in, JsonMap.ofJson(in).getString("A"), "B");
141 in = "{/*\tx\t*///\tx\t\n\t/*\tx\t*/A:'B','C':1,\"E\":[1,2,3],G:['g1','g2','g3']}";
142 checkStep(202, in, JsonMap.ofJson(in).getString("A"), "B");
143 in = "{A/*\tx\t*///\tx\t\n\t/*\tx\t*/:'B','C':1,\"E\":[1,2,3],G:['g1','g2','g3']}";
144 checkStep(203, in, JsonMap.ofJson(in).getString("A"), "B");
145 in = "{A:/*\tx\t*///\tx\t\n\t/*\tx\t*/'B','C':1,\"E\":[1,2,3],G:['g1','g2','g3']}";
146 checkStep(204, in, JsonMap.ofJson(in).getString("A"), "B");
147 in = "{A:'/*\tx\t*///\tx\t\n\t/*\tx\t*/B','C':1,\"E\":[1,2,3],G:['g1','g2','g3']}";
148 checkStep(205, in, JsonMap.ofJson(in).getString("A"), "/*\tx\t*///\tx\t\n\t/*\tx\t*/B");
149 in = "{A:'B/*\tx\t*///\tx\t\n\t/*\tx\t*/','C':1,\"E\":[1,2,3],G:['g1','g2','g3']}";
150 checkStep(206, in, JsonMap.ofJson(in).getString("A"), "B/*\tx\t*///\tx\t\n\t/*\tx\t*/");
151 in = "{A:'B'/*\tx\t*///\tx\t\n\t/*\tx\t*/,'C':1,\"E\":[1,2,3],G:['g1','g2','g3']}";
152 checkStep(207, in, JsonMap.ofJson(in).getString("A"), "B");
153 in = "{A:'B',/*\tx\t*///\tx\t\n\t/*\tx\t*/'C':1,\"E\":[1,2,3],G:['g1','g2','g3']}";
154 checkStep(208, in, JsonMap.ofJson(in).getString("C"), "1");
155 in = "{A:'B','C':/*\tx\t*///\tx\t\n\t/*\tx\t*/1,\"E\":[1,2,3],G:['g1','g2','g3']}";
156 checkStep(209, in, JsonMap.ofJson(in).getString("C"), "1");
157 in = "{A:'B','C':1/*\tx\t*///\tx\t\n\t/*\tx\t*/,\"E\":[1,2,3],G:['g1','g2','g3']}";
158 checkStep(210, in, JsonMap.ofJson(in).getString("C"), "1");
159 in = "{A:'B','C':1,/*\tx\t*///\tx\t\n\t/*\tx\t*/\"E\":[1,2,3],G:['g1','g2','g3']}";
160 checkStep(211, in, JsonMap.ofJson(in).getList("E").getString(0), "1");
161 in = "{A:'B','C':1,\"/*\tx\t*///\tx\t\n\t/*\tx\t*/E\":[1,2,3],G:['g1','g2','g3']}";
162 checkStep(212, in, JsonMap.ofJson(in).getList("/*\tx\t*///\tx\t\n\t/*\tx\t*/E").getString(0), "1");
163 in = "{A:'B','C':1,\"E/*\tx\t*///\tx\t\n\t/*\tx\t*/\":[1,2,3],G:['g1','g2','g3']}";
164 checkStep(213, in, JsonMap.ofJson(in).getList("E/*\tx\t*///\tx\t\n\t/*\tx\t*/").getString(0), "1");
165 in = "{A:'B','C':1,\"E\"/*\tx\t*///\tx\t\n\t/*\tx\t*/:[1,2,3],G:['g1','g2','g3']}";
166 checkStep(214, in, JsonMap.ofJson(in).getList("E").getString(0), "1");
167 in = "{A:'B','C':1,\"E\":/*\tx\t*///\tx\t\n\t/*\tx\t*/[1,2,3],G:['g1','g2','g3']}";
168 checkStep(215, in, JsonMap.ofJson(in).getList("E").getString(0), "1");
169 in = "{A:'B','C':1,\"E\":[/*\tx\t*///\tx\t\n\t/*\tx\t*/1,2,3],G:['g1','g2','g3']}";
170 checkStep(216, in, JsonMap.ofJson(in).getList("E").getString(0), "1");
171 in = "{A:'B','C':1,\"E\":[1/*\tx\t*///\tx\t\n\t/*\tx\t*/,2,3],G:['g1','g2','g3']}";
172 checkStep(217, in, JsonMap.ofJson(in).getList("E").getString(0), "1");
173 in = "{A:'B','C':1,\"E\":[1,/*\tx\t*///\tx\t\n\t/*\tx\t*/2,3],G:['g1','g2','g3']}";
174 checkStep(218, in, JsonMap.ofJson(in).getList("E").getString(1), "2");
175 in = "{A:'B','C':1,\"E\":[1,2/*\tx\t*///\tx\t\n\t/*\tx\t*/,3],G:['g1','g2','g3']}";
176 checkStep(219, in, JsonMap.ofJson(in).getList("E").getString(1), "2");
177 in = "{A:'B','C':1,\"E\":[1,2,/*\tx\t*///\tx\t\n\t/*\tx\t*/3],G:['g1','g2','g3']}";
178 checkStep(220, in, JsonMap.ofJson(in).getList("E").getString(2), "3");
179 in = "{A:'B','C':1,\"E\":[1,2,3]/*\tx\t*///\tx\t\n\t/*\tx\t*/,G:['g1','g2','g3']}";
180 checkStep(221, in, JsonMap.ofJson(in).getList("E").getString(2), "3");
181 in = "{A:'B','C':1,\"E\":[1,2,3],/*\tx\t*///\tx\t\n\t/*\tx\t*/G:['g1','g2','g3']}";
182 checkStep(222, in, JsonMap.ofJson(in).getList("G").getString(0), "g1");
183 in = "{A:'B','C':1,\"E\":[1,2,3],G:[/*\tx\t*///\tx\t\n\t/*\tx\t*/'g1','g2','g3']}";
184 checkStep(223, in, JsonMap.ofJson(in).getList("G").getString(0), "g1");
185 in = "{A:'B','C':1,\"E\":[1,2,3],G:['/*\tx\t*///\tx\t\n\t/*\tx\t*/g1','g2','g3']}";
186 checkStep(224, in, JsonMap.ofJson(in).getList("G").getString(0), "/*\tx\t*///\tx\t\n\t/*\tx\t*/g1");
187 in = "{A:'B','C':1,\"E\":[1,2,3],G:['g1'/*\tx\t*///\tx\t\n\t/*\tx\t*/,'g2','g3']}";
188 checkStep(225, in, JsonMap.ofJson(in).getList("G").getString(0), "g1");
189 in = "{A:'B','C':1,\"E\":[1,2,3],G:['g1',/*\tx\t*///\tx\t\n\t/*\tx\t*/'g2','g3']}";
190 checkStep(226, in, JsonMap.ofJson(in).getList("G").getString(1), "g2");
191 in = "{A:'B','C':1,\"E\":[1,2,3],G:['g1','g2'/*\tx\t*///\tx\t\n\t/*\tx\t*/,'g3']}";
192 checkStep(227, in, JsonMap.ofJson(in).getList("G").getString(1), "g2");
193 in = "{A:'B','C':1,\"E\":[1,2,3],G:['g1','g2',/*\tx\t*///\tx\t\n\t/*\tx\t*/'g3']}";
194 checkStep(228, in, JsonMap.ofJson(in).getList("G").getString(2), "g3");
195 in = "{A:'B','C':1,\"E\":[1,2,3],G:['g1','g2','g3'/*\tx\t*///\tx\t\n\t/*\tx\t*/]}";
196 checkStep(229, in, JsonMap.ofJson(in).getList("G").getString(2), "g3");
197 in = "{A:'B','C':1,\"E\":[1,2,3],G:['g1','g2','g3']/*\tx\t*///\tx\t\n\t/*\tx\t*/}";
198 checkStep(230, in, JsonMap.ofJson(in).getList("G").getString(2), "g3");
199 in = "{A:'B','C':1,\"E\":[1,2,3],G:['g1','g2','g3']}/*\tx\t*///\tx\t\n\t/*\tx\t*/";
200 checkStep(231, in, JsonMap.ofJson(in).getList("G").getString(2), "g3");
201
202 in = "{ /* x */ // x \n /* x */ A:'B','C':1,\"E\":[1,2,3],G:['g1','g2','g3']}";
203 checkStep(240, in, JsonMap.ofJson(in).getString("A"), "B");
204
205 in = "{A:'B','C':1,\"E\":[1,2,3],G:['g1','g2','g3']}";
206 checkStep(301, in, JsonMap.ofJson(in).getString("A", "default"), "B");
207 in = "{/*A:'B',*/'C':1,\"E\":[1,2,3],G:['g1','g2','g3']}";
208 checkStep(302, in, JsonMap.ofJson(in).getString("A", "default"), "default");
209 in = "{A:'B',/*'C':1,*/\"E\":[1,2,3],G:['g1','g2','g3']}";
210 checkStep(303, in, JsonMap.ofJson(in).getString("C", "default"), "default");
211 in = "{A:'B','C':1,/*\"E\":[1,2,3],*/G:['g1','g2','g3']}";
212 checkStep(304, in, JsonMap.ofJson(in).getString("E", "default"), "default");
213 in = "{A:'B','C':1,\"E\":[/*1,*/2,3],G:['g1','g2','g3']}";
214 checkStep(305, in, JsonMap.ofJson(in).getList("E").getString(0), "2");
215 in = "{A:'B','C':1,\"E\":[1,/*2,*/3],G:['g1','g2','g3']}";
216 checkStep(306, in, JsonMap.ofJson(in).getList("E").getString(1), "3");
217 in = "{A:'B','C':1,\"E\":[1,2/*,3*/],G:['g1','g2','g3']}";
218 checkStep(307, in, JsonMap.ofJson(in).getList("E").getString(1), "2");
219 in = "{A:'B','C':1,\"E\":[1,2,3],G:[/*'g1',*/'g2','g3']}";
220 checkStep(308, in, JsonMap.ofJson(in).getList("G").getString(0), "g2");
221 in = "{A:'B','C':1,\"E\":[1,2,3],G:['g1'/*,'g2'*/,'g3']}";
222 checkStep(309, in, JsonMap.ofJson(in).getList("G").getString(1), "g3");
223 in = "{A:'B','C':1,\"E\":[1,2,3],G:['g1','g2'/*,'g3'*/]}";
224 checkStep(310, in, JsonMap.ofJson(in).getList("G").getString(1), "g2");
225 in = "{A:'B','C':1,\"E\":[1,2,3],G:['g1','g2','g3']}";
226 checkStep(310, in, JsonMap.ofJson(in).getList("G").getString(1), "g2");
227
228
229 in = "{A:{B:[{C:'c0'},{C:'c1'},{C:'c2'}]}}";
230 checkStep(401, in, getDeepString(JsonMap.ofJson(in), "A/B/0/C"), "c0");
231 checkStep(402, in, getDeepString(JsonMap.ofJson(in), "A/B/1/C"), "c1");
232 checkStep(403, in, getDeepString(JsonMap.ofJson(in), "A/B/2/C"), "c2");
233
234
235 in = "{'𤭢𤭢':'𤭢𤭢'}";
236 checkStep(1, in, JsonMap.ofJson(in).getString("𤭢𤭢"), "𤭢𤭢");
237 }
238
239 private String getDeepString(JsonMap m, String url) {
240 var r = ObjectRest.create(m);
241 return (String)r.get(url);
242 }
243
244 private Boolean getDeepBoolean(JsonMap m, String url) {
245 var r = ObjectRest.create(m);
246 return (Boolean)r.get(url);
247 }
248
249 private void checkStep(int step, String input, String output, String expectedValue) {
250 if (!output.equals(expectedValue)) {
251 var msg = "Step #" + step + " failed: [" + input + "]->[" + output + "]...Expected value=[" + expectedValue + "]";
252 fail(msg);
253 }
254 }
255
256
257
258
259 @Test void a02_comparison() throws Exception {
260 var m1 = JsonMap.ofJson("{ firstName:'John', lastName:'Smith', age:123, isDeceased:false }");
261 var m2 = JsonMap.ofJson("{ age:123, isDeceased:false, lastName:'Smith', firstName:'John' }");
262
263 assertEquals(m1, m2);
264 }
265
266
267
268
269 @Test void a03_parent() throws Exception {
270 var m1 = JsonMap.ofJson("{a:1}");
271 var m2 = JsonMap.ofJson("{b:2}").inner(m1);
272
273 assertEquals(Integer.valueOf(1), m2.getInt("a"));
274 }
275
276
277
278
279 @Test void a04_updatability() throws Exception {
280 var m = JsonMap.ofJson("{a:[{b:'c'}]}");
281 var l = m.getList("a");
282 var m2 = l.getMap(0);
283 m2.put("b", "x");
284 assertBean(m, "a", "[{b=x}]");
285
286 m = JsonMap.ofJson("{a:[{b:'c'}]}");
287 for (JsonMap m3 : m.getList("a").elements(JsonMap.class))
288 m3.put("b", "y");
289
290 assertBean(m, "a", "[{b=y}]");
291 }
292
293
294
295
296 @Test void a05_atMethods() throws Exception {
297 var m = JsonMap.ofJson("{a:[{b:'c'}]}");
298 var r = m.getAt("a/0/b", String.class);
299
300 assertEquals("c", r);
301
302 m.putAt("a/0/b", "d");
303 r = m.getAt("a/0/b", String.class);
304 assertEquals("d", r);
305
306 m.postAt("a", "e");
307 r = m.getAt("a/1", String.class);
308 assertEquals("e", r);
309
310 m.deleteAt("a/1");
311 assertEquals("{a:[{b:'d'}]}", m.toString());
312 }
313
314
315
316
317 @Test void a06_fromReader() throws Exception {
318 assertBean(JsonMap.ofJson(reader("{foo:'bar'}")), "foo", "bar");
319 }
320
321
322
323
324 @Test void a07_getMap() throws Exception {
325 var m = JsonMap.ofJson("{a:{1:'true',2:'false'}}");
326 var m2 = m.getMap("a", Integer.class, Boolean.class, null);
327 assertJson("{'1':true,'2':false}", m2);
328 assertEquals(Integer.class, m2.keySet().iterator().next().getClass());
329 assertEquals(Boolean.class, m2.values().iterator().next().getClass());
330
331 m2 = m.getMap("b", Integer.class, Boolean.class, null);
332 assertNull(m2);
333
334 m2 = m.get("a", Map.class, Integer.class, Boolean.class);
335 assertJson("{'1':true,'2':false}", m2);
336 assertEquals(Integer.class, m2.keySet().iterator().next().getClass());
337 assertEquals(Boolean.class, m2.values().iterator().next().getClass());
338
339 m2 = m.get("b", Map.class, Integer.class, Boolean.class);
340 assertNull(m2);
341 }
342
343
344
345
346 @Test void a08_getList() throws Exception {
347 var m = JsonMap.ofJson("{a:['123','456']}");
348 var l2 = m.getList("a", Integer.class, null);
349 assertList(l2, "123", "456");
350 assertEquals(Integer.class, l2.iterator().next().getClass());
351
352 l2 = m.getList("b", Integer.class, null);
353 assertNull(l2);
354
355 l2 = m.get("a", List.class, Integer.class);
356 assertList(l2, "123", "456");
357 assertEquals(Integer.class, l2.iterator().next().getClass());
358
359 l2 = m.get("b", List.class, Integer.class);
360 assertNull(l2);
361 }
362 }