use of com.alibaba.fastjson.JSONPath in project fastjson by alibaba.
the class JSONPath_list_range method test_range.
public void test_range() throws Exception {
List list = new ArrayList();
list.add(new Object());
list.add(new Object());
list.add(new Object());
list.add(new Object());
list.add(new Object());
list.add(new Object());
list.add(new Object());
list.add(new Object());
list.add(new Object());
list.add(new Object());
JSONPath path = new JSONPath("$[2:4]");
List<Object> result = (List<Object>) path.eval(list);
Assert.assertEquals(3, result.size());
Assert.assertSame(list.get(2), result.get(0));
Assert.assertSame(list.get(3), result.get(1));
Assert.assertSame(list.get(4), result.get(2));
}
Aggregations