@@ -60,6 +60,35 @@ public void testRootBeans() throws Exception
60
60
assertEquals (3 , set .iterator ().next ().a );
61
61
}
62
62
63
+ public void testRootBeansInArray () throws Exception
64
+ {
65
+ final String JSON = "[{\" a\" :6}, {\" a\" :-7}]" ;
66
+
67
+ MappingIterator <Bean > it = MAPPER .reader (Bean .class ).readValues (JSON );
68
+
69
+ assertNotNull (it .getCurrentLocation ());
70
+ assertTrue (it .hasNext ());
71
+ Bean b = it .next ();
72
+ assertEquals (6 , b .a );
73
+ assertTrue (it .hasNext ());
74
+ b = it .next ();
75
+ assertEquals (-7 , b .a );
76
+ assertFalse (it .hasNext ());
77
+ it .close ();
78
+
79
+ // Also, test 'readAll()'
80
+ it = MAPPER .reader (Bean .class ).readValues (JSON );
81
+ List <Bean > all = it .readAll ();
82
+ assertEquals (2 , all .size ());
83
+ it .close ();
84
+
85
+ it = MAPPER .reader (Bean .class ).readValues ("[{\" a\" :4},{\" a\" :4}]" );
86
+ Set <Bean > set = it .readAll (new HashSet <Bean >());
87
+ assertEquals (HashSet .class , set .getClass ());
88
+ assertEquals (1 , set .size ());
89
+ assertEquals (4 , set .iterator ().next ().a );
90
+ }
91
+
63
92
public void testRootMaps () throws Exception
64
93
{
65
94
final String JSON = "{\" a\" :3}{\" a\" :27} " ;
@@ -120,7 +149,7 @@ public void testRootArraysWithParser() throws Exception
120
149
assertEquals (3 , array [0 ]);
121
150
assertFalse (it .hasNext ());
122
151
}
123
-
152
+
124
153
public void testHasNextWithEndArray () throws Exception {
125
154
final String JSON = "[1,3]" ;
126
155
JsonParser jp = MAPPER .getFactory ().createParser (JSON );
@@ -140,7 +169,7 @@ public void testHasNextWithEndArray() throws Exception {
140
169
assertFalse (it .hasNext ());
141
170
assertFalse (it .hasNext ());
142
171
}
143
-
172
+
144
173
public void testHasNextWithEndArrayManagedParser () throws Exception {
145
174
final String JSON = "[1,3]" ;
146
175
@@ -154,7 +183,7 @@ public void testHasNextWithEndArrayManagedParser() throws Exception {
154
183
assertFalse (it .hasNext ());
155
184
assertFalse (it .hasNext ());
156
185
}
157
-
186
+
158
187
/*
159
188
/**********************************************************
160
189
/* Unit tests; non-root arrays
0 commit comments