11package com .jsoniter ;
22
3+ import com .jsoniter .annotation .JsonIgnore ;
34import com .jsoniter .any .Any ;
45import junit .framework .TestCase ;
56import org .junit .Assert ;
@@ -25,4 +26,22 @@ public void test_array_of_objects() throws IOException {
2526 Any any = iter .readAny ();
2627 assertEquals ("22" , any .toString (1 , "field2" ));
2728 }
29+
30+ public void test_get_all_array_elements_via_any () throws IOException {
31+ Any any = JsonIterator .deserialize (" [ { \" bar\" : 1 }, {\" bar\" : 3} ]" );
32+ Any result = any .get ('*' , "bar" );
33+ assertEquals ("[ 1, 3]" , result .toString ());
34+ any = Any .wrapAnyList (any .asList ()); // make it not lazy
35+ result = any .get ('*' , "bar" );
36+ assertEquals ("[ 1, 3]" , result .toString ());
37+ }
38+
39+ public void test_get_all_object_values_via_any () throws IOException {
40+ Any any = JsonIterator .deserialize ("{\" field1\" :[1,2],\" field2\" :[3,4]}" );
41+ Any result = any .get ('*' , 1 );
42+ assertEquals ("{\" field1\" :2,\" field2\" :4}" , result .toString ());
43+ any = Any .wrapAnyMap (any .asMap ()); // make it not lazy
44+ result = any .get ('*' , 1 );
45+ assertEquals ("{\" field1\" :2,\" field2\" :4}" , result .toString ());
46+ }
2847}
0 commit comments