forked from json-iterator/java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestNested.java
More file actions
28 lines (25 loc) · 915 Bytes
/
TestNested.java
File metadata and controls
28 lines (25 loc) · 915 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package com.jsoniter;
import com.jsoniter.any.Any;
import junit.framework.TestCase;
import org.junit.Assert;
import java.io.IOException;
public class TestNested extends TestCase {
public void test_array_of_objects() throws IOException {
JsonIterator iter = JsonIterator.parse(
"[{'field1':'11','field2':'12'},{'field1':'21','field2':'22'}]".replace('\'', '"'));
SimpleObject[] objects = iter.read(SimpleObject[].class);
Assert.assertArrayEquals(new SimpleObject[]{
new SimpleObject() {{
field1 = "11";
field2 = "12";
}},
new SimpleObject() {{
field1 = "21";
field2 = "22";
}}
}, objects);
iter.reset(iter.buf);
Any any = iter.readAny();
assertEquals("22", any.toString(1, "field2"));
}
}