use of com.alibaba.fastjson.JSONPath in project fastjson by alibaba.
the class JSONPath_list_size_1 method test_obj_array.
public void test_obj_array() throws Exception {
Object[] array = new Object[] { 1, 2, 3 };
JSONPath path = new JSONPath("$.size()");
Integer result = (Integer) path.eval(array);
Assert.assertEquals(array.length, result.intValue());
}
use of com.alibaba.fastjson.JSONPath in project fastjson by alibaba.
the class JSONPath_list_size_1 method test_int_array.
public void test_int_array() throws Exception {
int[] array = new int[] { 1, 2, 3 };
JSONPath path = new JSONPath("$.size()");
Integer result = (Integer) path.eval(array);
Assert.assertEquals(array.length, result.intValue());
}
use of com.alibaba.fastjson.JSONPath in project fastjson by alibaba.
the class JSONPath_list_size_2 method test_map.
public void test_map() throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
map.put("1001", 1001);
map.put("1002", 1002);
JSONPath path = new JSONPath("$.size()");
Integer result = (Integer) path.eval(map);
Assert.assertEquals(map.size(), result.intValue());
}
use of com.alibaba.fastjson.JSONPath in project fastjson by alibaba.
the class JSONPath_list_size_2 method test_map_null.
public void test_map_null() throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
map.put("1001", 1001);
map.put("1002", 1002);
map.put("1003", null);
JSONPath path = new JSONPath("$.size()");
Integer result = (Integer) path.eval(map);
Assert.assertEquals(2, result.intValue());
}
use of com.alibaba.fastjson.JSONPath in project fastjson by alibaba.
the class JSONPath_list_size_3 method test_java_bean_field_null.
public void test_java_bean_field_null() throws Exception {
Model model = new Model();
model.id = 1001;
model.name = null;
JSONPath path = new JSONPath("$.size()");
Integer result = (Integer) path.eval(model);
Assert.assertEquals(1, result.intValue());
}
Aggregations