本文整理了Java中com.alibaba.fastjson.JSONPath.compile()
方法的一些代码示例,展示了JSONPath.compile()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSONPath.compile()
方法的具体详情如下:
包路径:com.alibaba.fastjson.JSONPath
类名称:JSONPath
方法名:compile
暂无
代码示例来源:origin: alibaba/fastjson
public static boolean contains(Object rootObject, String path) {
if (rootObject == null) {
return false;
}
JSONPath jsonpath = compile(path);
return jsonpath.contains(rootObject);
}
代码示例来源:origin: alibaba/fastjson
public static void arrayAdd(Object rootObject, String path, Object... values) {
JSONPath jsonpath = compile(path);
jsonpath.arrayAdd(rootObject, values);
}
代码示例来源:origin: alibaba/fastjson
public static boolean containsValue(Object rootObject, String path, Object value) {
JSONPath jsonpath = compile(path);
return jsonpath.containsValue(rootObject, value);
}
代码示例来源:origin: alibaba/fastjson
public static boolean set(Object rootObject, String path, Object value) {
JSONPath jsonpath = compile(path);
return jsonpath.set(rootObject, value);
}
代码示例来源:origin: alibaba/fastjson
public static Object eval(Object rootObject, String path) {
JSONPath jsonpath = compile(path);
return jsonpath.eval(rootObject);
}
代码示例来源:origin: alibaba/fastjson
public static boolean remove(Object root, String path) {
JSONPath jsonpath = compile(path);
return jsonpath.remove(root);
}
代码示例来源:origin: alibaba/fastjson
public static int size(Object rootObject, String path) {
JSONPath jsonpath = compile(path);
Object result = jsonpath.eval(rootObject);
return jsonpath.evalSize(result);
}
代码示例来源:origin: com.alibaba/fastjson
public static boolean contains(Object rootObject, String path) {
if (rootObject == null) {
return false;
}
JSONPath jsonpath = compile(path);
return jsonpath.contains(rootObject);
}
代码示例来源:origin: alibaba/fastjson
/**
* Compile jsonPath and use it to extract keySet or field names from rootObject.
*
* @param rootObject Can be a map or custom object. Array and Collection are not supported.
* @param path JSONPath string to be compiled.
* @return Set of keys, or <code>null</code> if not supported.
*/
public static Set<?> keySet(Object rootObject, String path) {
JSONPath jsonpath = compile(path);
Object result = jsonpath.eval(rootObject);
return jsonpath.evalKeySet(result);
}
代码示例来源:origin: alibaba/fastjson
/**
* @since 1.2.9
* @param json
* @param path
* @return
*/
public static Object read(String json, String path) {
return compile(path)
.eval(
JSON.parse(json)
);
}
代码示例来源:origin: com.alibaba/fastjson
public static Object eval(Object rootObject, String path) {
JSONPath jsonpath = compile(path);
return jsonpath.eval(rootObject);
}
代码示例来源:origin: com.alibaba/fastjson
public static boolean containsValue(Object rootObject, String path, Object value) {
JSONPath jsonpath = compile(path);
return jsonpath.containsValue(rootObject, value);
}
代码示例来源:origin: com.alibaba/fastjson
public static void arrayAdd(Object rootObject, String path, Object... values) {
JSONPath jsonpath = compile(path);
jsonpath.arrayAdd(rootObject, values);
}
代码示例来源:origin: com.alibaba/fastjson
public static boolean set(Object rootObject, String path, Object value) {
JSONPath jsonpath = compile(path);
return jsonpath.set(rootObject, value);
}
代码示例来源:origin: com.alibaba/fastjson
public static boolean remove(Object root, String path) {
JSONPath jsonpath = compile(path);
return jsonpath.remove(root);
}
代码示例来源:origin: alibaba/fastjson
/**
* @since 1.2.51
* @param json
* @param path
* @return
*/
public static Object extract(String json, String path, ParserConfig config, int features, Feature... optionFeatures) {
features |= Feature.OrderedField.mask;
DefaultJSONParser parser = new DefaultJSONParser(json, config, features);
JSONPath jsonPath = compile(path);
Object result = jsonPath.extract(parser);
parser.lexer.close();
return result;
}
代码示例来源:origin: com.alibaba/fastjson
/**
* @since 1.2.9
* @param json
* @param path
* @return
*/
public static Object read(String json, String path) {
return compile(path)
.eval(
JSON.parse(json)
);
}
代码示例来源:origin: com.alibaba/fastjson
public static int size(Object rootObject, String path) {
JSONPath jsonpath = compile(path);
Object result = jsonpath.eval(rootObject);
return jsonpath.evalSize(result);
}
代码示例来源:origin: com.alibaba/fastjson
/**
* Compile jsonPath and use it to extract keySet or field names from rootObject.
*
* @param rootObject Can be a map or custom object. Array and Collection are not supported.
* @param path JSONPath string to be compiled.
* @return Set of keys, or <code>null</code> if not supported.
*/
public static Set<?> keySet(Object rootObject, String path) {
JSONPath jsonpath = compile(path);
Object result = jsonpath.eval(rootObject);
return jsonpath.evalKeySet(result);
}
代码示例来源:origin: com.alibaba/fastjson
/**
* @since 1.2.51
* @param json
* @param path
* @return
*/
public static Object extract(String json, String path, ParserConfig config, int features, Feature... optionFeatures) {
features |= Feature.OrderedField.mask;
DefaultJSONParser parser = new DefaultJSONParser(json, config, features);
JSONPath jsonPath = compile(path);
Object result = jsonPath.extract(parser);
parser.lexer.close();
return result;
}
内容来源于网络,如有侵权,请联系作者删除!