com.atlassian.jira.util.json.JSONObject.optJSONArray()方法的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(3.3k)|赞(0)|评价(0)|浏览(177)

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

JSONObject.optJSONArray介绍

[英]Get an optional JSONArray associated with a key. It returns null if there is no such key, or if its value is not a JSONArray.
[中]获取与键关联的可选JSONArray。如果没有这样的键,或者其值不是JSONArray,则返回null。

代码示例

代码示例来源:origin: com.atlassian.plugin.deflection/deflection-cse

public static boolean resultMatches(JSONObject result, Iterable<String> patternToMatch) throws JSONException
  {
    final JSONArray labels = result.optJSONArray("perResultLabels");
    if (labels != null)
    {
      for (int idx = 0; idx < labels.length(); idx++)
      {
        String label = labels.getJSONObject(idx).getString("label");
        for (String pattern : patternToMatch)
        {
          if (label.equals(pattern))
          {
            return true;
          }
        }
      }
    }
    return false;
  }
}

代码示例来源:origin: com.atlassian.plugin.automation/jira-automation-spi

private JSONArray parseExistingArray(final String existingJson)
{
  JSONArray jsonArray = new JSONArray();
  try
  {
    jsonArray = new JSONObject(existingJson).optJSONArray(ALL_KEY);
  }
  catch (JSONException e)
  {
    // swallow the exception
  }
  jsonArray.put(createJSONEntry(timestamp, entry));
  return jsonArray;
}

代码示例来源:origin: com.atlassian.plugin.deflection/deflection-cse

@Override
public final boolean shouldAddResult(JSONObject result) throws JSONException
{
  final JSONArray labels = result.optJSONArray("perResultLabels");
  if (labels != null)
  {
    for (int idx = 0; idx < labels.length(); idx++)
    {
      String label = labels.getJSONObject(idx).getString("label");
      if (CAC.equals(label))
      {
        return ConfluenceResultMatcher.resultMatches(result, getCacPattern());
      }
      else if (JAC.equals(label))
      {
        return JIRAResultMatcher.resultMatches(result, getJacPattern());
      }
      else if (AAC.equals(label))
      {
        return AnswersResultMatcher.resultMatches(result, getAacPattern());
      }
    }
  }
  // No matching response parser, so we don't know whether to add. Return false for now
  return false;
}

代码示例来源:origin: com.marvelution.jira.plugins/jira-jenkins-plugin

build.setTimestamp(jsonBuild.getLong("timestamp"));
build.setDuration(jsonBuild.getLong("duration"));
final JSONArray actions = jsonBuild.optJSONArray("actions");
if (actions != null) {
  for (int index = 0; index < actions.length(); index++) {
      JSONArray causes = object.optJSONArray("causes");
      for (int ii = 0; ii < causes.length(); ii++) {
        final JSONObject cause = causes.getJSONObject(ii);
final JSONArray artifacts = jsonBuild.optJSONArray("artifacts");
if (artifacts != null && artifacts.length() > 0) {
  for (int index = 0; index < artifacts.length(); index++) {
final JSONArray culprits = jsonBuild.optJSONArray("culprits");
if (culprits != null && culprits.length() > 0) {
  for (int index = 0; index < culprits.length(); index++) {
  final JSONObject changeSet = jsonBuild.optJSONObject("changeSet");
  if (changeSet != null && changeSet.has("items")) {
    final JSONArray items = changeSet.optJSONArray("items");
    if (items != null && items.length() > 0) {
      for (int index = 0; index < items.length(); index++) {

代码示例来源:origin: com.marvelution.jira.plugins/jira-jenkins-plugin

job.setOldestBuild(firstBuild.optInt("number", -1));
final JSONArray builds = json.optJSONArray("builds");
if (builds != null && builds.length() > 0) {
  for (int index = 0; index < builds.length(); index++) {

相关文章