org.json.JSONArray.query()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(2.6k)|赞(0)|评价(0)|浏览(127)

本文整理了Java中org.json.JSONArray.query()方法的一些代码示例,展示了JSONArray.query()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSONArray.query()方法的具体详情如下:
包路径:org.json.JSONArray
类名称:JSONArray
方法名:query

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));
}

相关文章