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

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

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

JSONObject.getJSONArray介绍

[英]Get the JSONArray value associated with a key.
[中]获取与键关联的JSONArray值。

代码示例

代码示例来源:origin: com.atlassian.jira/jira-api

public static UserFilter fromJson(JSONObject json) throws JSONException
{
  checkNotNull(json, "json");
  boolean isEnabled = json.getBoolean(KEY_ENABLED);
  if (!isEnabled)
  {
    return UserFilter.DISABLED;
  }
  return new UserFilter(true, getRoleIds(json.getJSONArray(KEY_ROLEIDS)), getGroups(json.getJSONArray(KEY_GROUPS)));
}

代码示例来源:origin: com.atlassian.jira/jira-core

private List<SearchRequest> toSearchRequests(final ApplicationUser user, final JSONObject json) throws JSONException
{
  final JSONArray jsonArray = json.getJSONArray(IDS);
  final List<SearchRequest> filters = Lists.newArrayList();
  for (int i = 0; i < jsonArray.length(); i++)
  {
    final long filterId = jsonArray.getLong(i);
    final SearchRequest filter = searchRequestService.getFilter(new JiraServiceContextImpl(user), filterId);
    if (filter != null)
    {
      filters.add(filter);
    }
  }
  return ImmutableList.copyOf(filters);
}

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

protected List<SearchResult> searchJQL(int filterID, String filterName) throws IOException, JSONException
{
  List<SearchResult> results = Lists.newArrayList();
  JSONArray issueList = new JSONObject(searchResults(filterID)).getJSONArray("issues");
  for (int i = 0; i < issueList.length(); i++)
  {
    JSONObject issue = issueList.getJSONObject(i);
    String title = issue.getString("key");
    String content = issue.getJSONObject("fields").getString("summary");
    String url = JAC_BASE_URL + "/browse/" + issue.getString("key");
    String source = "HotIssues" + filterName;
    results.add(new DefaultSearchResult(content, url, title, source, ""));
  }
  return results;
}

代码示例来源:origin: com.atlassian.jira/jira-issue-link-remote-jira-plugin

private static ErrorCollection convertResponseToErrorCollection(final JSONObject json, final RestVersion restVersion) throws JSONException
{
  final ErrorCollection errors = new SimpleErrorCollection();
  switch (restVersion)
  {
    case VERSION_2_0alpha1:
    case VERSION_2:
    {
      final JSONArray errorMessages = json.getJSONArray("errorMessages");
      for (int i = 0; i < errorMessages.length(); i++)
      {
        errors.addErrorMessage(errorMessages.getString(i));
      }
      final JSONObject errorsMap = json.getJSONObject("errors");
      final Iterator<String> keys = errorsMap.keys();
      while (keys.hasNext())
      {
        final String key = keys.next();
        errors.addError(key, errorsMap.getString(key));
      }
      break;
    }
    default:
    {
      throw new UnsupportedOperationException("Unsupported REST version: " + restVersion);
    }
  }
  return errors;
}

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

private static ErrorCollection convertJsonToErrorCollection(final JSONObject json)
{
  final ErrorCollection errors = new SimpleErrorCollection();
  try
  {
    final JSONArray errorMessages = json.getJSONArray("errorMessages");
    for (int i = 0; i < errorMessages.length(); i++)
    {
      errors.addErrorMessage(errorMessages.getString(i));
    }
    final JSONObject errorsMap = json.getJSONObject("errors");
    final Iterator<String> keys = errorsMap.keys();
    while (keys.hasNext())
    {
      final String key = keys.next();
      errors.addError(key, errorsMap.getString(key));
    }
  }
  catch (final JSONException e)
  {
    return null;
  }
  return errors;
}

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

JSONArray jsonResults = searchResult.getJSONArray("results");

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

@Override
public List<Job> getJobs() {
  List<Job> jobs = Lists.newArrayList();
  try {
    RestResponse response = executeGetRequest("/api/json", CALL_TIMEOUT);
    if (response.getJson() != null && response.getJson().has("jobs")) {
      JSONArray json = response.getJson().getJSONArray("jobs");
      LOGGER.info("Found {} jobs", new Object[] { json.length() });
      for (int index = 0; index < json.length(); index++) {
        final JSONObject jsonJob = json.getJSONObject(index);
        jobs.add(new Job(site.getId(), jsonJob.getString("name")));
      }
    } else {
      handleNoJsonResponse(response);
    }
  } catch (CredentialsRequiredException e) {
    LOGGER.error("Authentication failure on {} [{}]: {}", new Object[] { applicationLink.getName(),
                                       applicationLink.getDisplayUrl(), e.getMessage() });
  } catch (JSONException e) {
    LOGGER.error("Failed to get the Job list from {}: {}", applicationLink.getName(), e.getMessage());
  }
  return jobs;
}

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

RESULTS_PER_QUERY));
JSONArray jsonResults = searchResult.getJSONArray("results");

代码示例来源:origin: com.atlassian.jirawallboard/atlassian-wallboard-plugin

static public WallboardPluginSettings loadSettings(PluginSettingsFactory pluginSettingsFactory, ApplicationUser user)
{
  WallboardPluginSettings settings = new WallboardPluginSettings(pluginSettingsFactory, user);
  Object val = pluginSettingsFactory.createGlobalSettings().get(WALLBOARD_KEY + mapNullToBlank(settings.userKey));
  if (val == null)
  {
    settings.isConfigured = false;
    return settings;
  }
  JSONObject jsonRepresentation;
  try
  {
    jsonRepresentation = new JSONObject((String) val);
    JSONArray rawDashboardIds = jsonRepresentation.getJSONArray("dashboardIds");
    settings.dashboardIds = new ArrayList<>(rawDashboardIds.length());
    for (int i = 0; i < rawDashboardIds.length(); i++)
    {
      settings.dashboardIds.add(i, (String) rawDashboardIds.get(i));
    }
    settings.setCyclePeriod(jsonRepresentation.getInt(WallboardServlet.CYCLE_PERIOD.getKey()));
    settings.setTransitionFx(jsonRepresentation.getString(WallboardServlet.TRANSITION_FX.getKey()));
    settings.setRandom(jsonRepresentation.getBoolean(WallboardServlet.RANDOM.getKey()));
  }
  catch (JSONException e)
  {
    settings.isConfigured = false;
  }
  return settings;
}

相关文章