本文整理汇总了Java中com.alibaba.fastjson.JSONPath.compile方法的典型用法代码示例。如果您正苦于以下问题:Java JSONPath.compile方法的具体用法?Java JSONPath.compile怎么用?Java JSONPath.compile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alibaba.fastjson.JSONPath
的用法示例。
在下文中一共展示了JSONPath.compile方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test_path_size_1
import com.alibaba.fastjson.JSONPath; //导入方法依赖的package包/类
public void test_path_size_1() throws Exception {
List list = new ArrayList();
list.add(new Entity(101, "kiki"));
list.add(new Entity(102, "ljw2083"));
list.add(new Entity(103, "ljw2083"));
JSONPath path = JSONPath.compile("$");
Assert.assertEquals(3, path.size(list));
}
示例2: test_path_size_2
import com.alibaba.fastjson.JSONPath; //导入方法依赖的package包/类
public void test_path_size_2() throws Exception {
List list = new ArrayList();
list.add(new Entity(101, "kiki"));
list.add(new Entity(102, "ljw2083"));
list.add(new Entity(103, "ljw2083"));
JSONObject root = new JSONObject();
root.put("values", list);
JSONPath path = JSONPath.compile("$.values");
Assert.assertEquals(3, path.size(root));
}
示例3: test_path_empty
import com.alibaba.fastjson.JSONPath; //导入方法依赖的package包/类
public void test_path_empty() throws Exception {
Throwable error = null;
try {
JSONPath.compile("");
} catch (JSONPathException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
示例4: test_path_null
import com.alibaba.fastjson.JSONPath; //导入方法依赖的package包/类
public void test_path_null() throws Exception {
Throwable error = null;
try {
JSONPath.compile(null);
} catch (JSONPathException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
示例5: test_path_size
import com.alibaba.fastjson.JSONPath; //导入方法依赖的package包/类
public void test_path_size() throws Exception {
JSONPath path = JSONPath.compile("$");
Assert.assertEquals(-1, path.size(null));
}
示例6: test_jsonpath
import com.alibaba.fastjson.JSONPath; //导入方法依赖的package包/类
public void test_jsonpath() throws Exception {
Model model = new Model();
JSONPath path = JSONPath.compile("/value/id");
path.set(model, 123);
assertNotNull(model.value);
}