org.codehaus.jettison.json.JSONObject.toJSONArray()方法的使用及代码示例

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

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

JSONObject.toJSONArray介绍

[英]Produce a JSONArray containing the values of the members of this JSONObject.
[中]生成包含此JSONObject成员值的JSONArray。

代码示例

代码示例来源:origin: com.atlassian.jira/jira-rest-java-client

static Collection<String> extractErrors(String body) throws JSONException {
  JSONObject jsonObject = new JSONObject(body);
  final Collection<String> errorMessages = new ArrayList<String>();
  final JSONArray errorMessagesJsonArray = jsonObject.optJSONArray("errorMessages");
  if (errorMessagesJsonArray != null) {
    errorMessages.addAll(JsonParseUtil.toStringCollection(errorMessagesJsonArray));
  }
  final JSONObject errorJsonObject = jsonObject.optJSONObject("errors");
  if (errorJsonObject != null) {
    final JSONArray valuesJsonArray = errorJsonObject.toJSONArray(errorJsonObject.names());
    if (valuesJsonArray != null) {
      errorMessages.addAll(JsonParseUtil.toStringCollection(valuesJsonArray));
    }
  }
  return errorMessages;
}

代码示例来源:origin: com.atlassian.jira/jira-rest-java-client-p3

static Collection<String> extractErrors(String body) throws JSONException {
  JSONObject jsonObject = new JSONObject(body);
  final Collection<String> errorMessages = new ArrayList<String>();
  final JSONArray errorMessagesJsonArray = jsonObject.optJSONArray("errorMessages");
  if (errorMessagesJsonArray != null) {
    errorMessages.addAll(JsonParseUtil.toStringCollection(errorMessagesJsonArray));
  }
  final JSONObject errorJsonObject = jsonObject.optJSONObject("errors");
  if (errorJsonObject != null) {
    final JSONArray valuesJsonArray = errorJsonObject.toJSONArray(errorJsonObject.names());
    if (valuesJsonArray != null) {
      errorMessages.addAll(JsonParseUtil.toStringCollection(valuesJsonArray));
    }
  }
  return errorMessages;
}

代码示例来源:origin: com.atlassian.jira/jira-rest-java-client-p3

static Collection<String> extractErrors(String body) throws JSONException {
  JSONObject jsonObject = new JSONObject(body);
  final Collection<String> errorMessages = new ArrayList<String>();
  final JSONArray errorMessagesJsonArray = jsonObject.optJSONArray("errorMessages");
  if (errorMessagesJsonArray != null) {
    errorMessages.addAll(JsonParseUtil.toStringCollection(errorMessagesJsonArray));
  }
  final JSONObject errorJsonObject = jsonObject.optJSONObject("errors");
  if (errorJsonObject != null) {
    final JSONArray valuesJsonArray = errorJsonObject.toJSONArray(errorJsonObject.names());
    if (valuesJsonArray != null) {
      errorMessages.addAll(JsonParseUtil.toStringCollection(valuesJsonArray));
    }
  }
  return errorMessages;
}

相关文章