本文整理了Java中org.json.JSONArray.query()
方法的一些代码示例,展示了JSONArray.query()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSONArray.query()
方法的具体详情如下:
包路径:org.json.JSONArray
类名称:JSONArray
方法名:query
[英]Creates a JSONPointer using an initialization string and tries to match it to an item within this JSONArray. For example, given a JSONArray initialized with this document:
[
{"b":"c"}
]
and this JSONPointer string:
"/0/b"
Then this method will return the String "c" A JSONPointerException may be thrown from code called by this method.
[中]使用初始化字符串创建JSONPointer,并尝试将其与此JSONArray中的项相匹配。例如,给定一个使用以下文档初始化的JSONArray:
[
{"b":"c"}
]
和此JSONPointer字符串:
"/0/b"
则此方法将返回字符串“c”,此方法调用的代码可能会引发JSONPointerException。
代码示例来源:origin: loklak/loklak_server
/**
* Creates a JSONPointer using an initialization string and tries to
* match it to an item within this JSONArray. For example, given a
* JSONArray initialized with this document:
* <pre>
* [
* {"b":"c"}
* ]
* </pre>
* and this JSONPointer string:
* <pre>
* "/0/b"
* </pre>
* Then this method will return the String "c"
* A JSONPointerException may be thrown from code called by this method.
*
* @param jsonPointer string that can be used to create a JSONPointer
* @return the item matched by the JSONPointer, otherwise null
*/
public Object query(String jsonPointer) {
return query(new JSONPointer(jsonPointer));
}
代码示例来源:origin: b3log/latke
/**
* Creates a JSONPointer using an initialization string and tries to
* match it to an item within this JSONArray. For example, given a
* JSONArray initialized with this document:
* <pre>
* [
* {"b":"c"}
* ]
* </pre>
* and this JSONPointer string:
* <pre>
* "/0/b"
* </pre>
* Then this method will return the String "c"
* A JSONPointerException may be thrown from code called by this method.
*
* @param jsonPointer string that can be used to create a JSONPointer
* @return the item matched by the JSONPointer, otherwise null
*/
public Object query(String jsonPointer) {
return query(new JSONPointer(jsonPointer));
}
代码示例来源:origin: org.b3log/latke
/**
* Creates a JSONPointer using an initialization string and tries to
* match it to an item within this JSONArray. For example, given a
* JSONArray initialized with this document:
* <pre>
* [
* {"b":"c"}
* ]
* </pre>
* and this JSONPointer string:
* <pre>
* "/0/b"
* </pre>
* Then this method will return the String "c"
* A JSONPointerException may be thrown from code called by this method.
*
* @param jsonPointer string that can be used to create a JSONPointer
* @return the item matched by the JSONPointer, otherwise null
*/
public Object query(String jsonPointer) {
return query(new JSONPointer(jsonPointer));
}
内容来源于网络,如有侵权,请联系作者删除!