use of com.alibaba.fastjson.JSONPath in project fastjson by alibaba.
the class JSONPath_field_access_filter_notNull method test_list_map.
public void test_list_map() throws Exception {
JSONPath path = new JSONPath("$[?(@.name)]");
List<Entity> entities = new ArrayList<Entity>();
entities.add(new Entity(1001, "ljw2083"));
entities.add(new Entity(1002, "wenshao"));
entities.add(new Entity(1003, null));
List<Object> result = (List<Object>) path.eval(entities);
Assert.assertEquals(2, result.size());
Assert.assertSame(entities.get(0), result.get(0));
Assert.assertSame(entities.get(1), result.get(1));
}
use of com.alibaba.fastjson.JSONPath in project fastjson by alibaba.
the class JSONPath_field_access_filter_rlike method test_list_like_contains.
public void test_list_like_contains() throws Exception {
JSONPath path = new JSONPath("$[?(@.name like '%208%')]");
List<Entity> entities = new ArrayList<Entity>();
entities.add(new Entity(1001, "ljw2083"));
entities.add(new Entity(1002, "wenshao"));
entities.add(new Entity(1003, "yakolee"));
entities.add(new Entity(null, null));
List<Object> result = (List<Object>) path.eval(entities);
Assert.assertEquals(1, result.size());
Assert.assertSame(entities.get(0), result.get(0));
}
use of com.alibaba.fastjson.JSONPath in project fastjson by alibaba.
the class JSONPath_field_access_filter_rlike method test_list_like_extract.
public void test_list_like_extract() throws Exception {
JSONPath path = new JSONPath("$[name rlike 'ljw2083']");
List<Entity> entities = new ArrayList<Entity>();
entities.add(new Entity(1001, "ljw2083"));
entities.add(new Entity(1002, "wenshao"));
entities.add(new Entity(1003, null));
entities.add(new Entity(null, null));
List<Object> result = (List<Object>) path.eval(entities);
Assert.assertEquals(1, result.size());
Assert.assertSame(entities.get(0), result.get(0));
}
use of com.alibaba.fastjson.JSONPath in project fastjson by alibaba.
the class JSONPath_field_access_filter_compare_string method test_list_lt.
public void test_list_lt() throws Exception {
JSONPath path = new JSONPath("$[?(@.name < 'wenshao')]");
List<Entity> entities = new ArrayList<Entity>();
entities.add(new Entity(1001, "ljw2083"));
entities.add(new Entity(1002, "wenshao"));
entities.add(new Entity(1003, null));
entities.add(new Entity(null, null));
List<Object> result = (List<Object>) path.eval(entities);
Assert.assertEquals(1, result.size());
Assert.assertSame(entities.get(0), result.get(0));
}
use of com.alibaba.fastjson.JSONPath in project fastjson by alibaba.
the class JSONPath_field_access_filter_compare_string method test_list_le.
public void test_list_le() throws Exception {
JSONPath path = new JSONPath("$[?(@.name <= 'wenshao')]");
List<Entity> entities = new ArrayList<Entity>();
entities.add(new Entity(1001, "ljw2083"));
entities.add(new Entity(1002, "wenshao"));
entities.add(new Entity(1003, null));
entities.add(new Entity(null, null));
List<Object> result = (List<Object>) path.eval(entities);
Assert.assertEquals(2, result.size());
Assert.assertSame(entities.get(0), result.get(0));
Assert.assertSame(entities.get(1), result.get(1));
}
Aggregations