本文整理了Java中com.atlassian.jira.util.json.JSONArray.getJSONObject()
方法的一些代码示例,展示了JSONArray.getJSONObject()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSONArray.getJSONObject()
方法的具体详情如下:
包路径:com.atlassian.jira.util.json.JSONArray
类名称:JSONArray
方法名:getJSONObject
[英]Get the JSONObject associated with an index.
[中]获取与索引关联的JSONObject。
代码示例来源:origin: com.atlassian.jira/jira-core
public static AttachmentArchive fromJSONArrayQuiet(final String jsonArrayString, final int maxSize)
{
try
{
final JSONArray jsonArray = new JSONArray(jsonArrayString);
final ImmutableList.Builder<AttachmentArchiveEntry> builder = ImmutableList.builder();
final int maxIndex = Math.min(jsonArray.length(), maxSize);
for (int i = 0; i < maxIndex; i++)
{
builder.add(FROM_JSON.apply(jsonArray.getJSONObject(i)));
}
final List<AttachmentArchiveEntry> entries = builder.build();
return new AttachmentArchiveImpl(entries, jsonArray.length());
}
catch (final JSONException ignore)
{
log.error(String.format("Invalid jsonArray supplied: %s", jsonArrayString));
return null;
}
}
代码示例来源:origin: com.atlassian.jira/jira-core
private Collection<RemoteProject> parseProjects(final String response, final ApplicationLink applicationLink)
throws ResponseException, CredentialsRequiredException
{
try
{
JSONArray json = new JSONArray(response);
int length = json.length();
final Collection<RemoteProject> projects = new ArrayList<RemoteProject>(length);
for (int i = 0; i < length; i++)
{
projects.add(RemoteProject.from(applicationLink, json.getJSONObject(i)));
}
return projects;
}
catch (JSONException ex)
{
throw new RuntimeException("Unable to parse the JSON response for get projects : " + response, ex);
}
}
}
代码示例来源:origin: com.atlassian.jira/jira-core
public static ImmutableMap<String, JSONObject> getCommentPropertiesFromParameters(final Map<String, Object> commentParams)
throws JSONException
{
if (commentParams.containsKey(PARAM_COMMENT_PROPERTY))
{
final String[] array = (String[]) commentParams.get(PARAM_COMMENT_PROPERTY);
if (array != null && array.length == 1)
{
final JSONArray jsonArray = new JSONArray(array[0]);
final ImmutableMap.Builder<String, JSONObject> builder = ImmutableMap.builder();
for (int i = 0; i < jsonArray.length(); i++)
{
JSONObject object = jsonArray.getJSONObject(i);
builder.put(object.getString("key"), object.getJSONObject("value"));
}
return builder.build();
}
}
return ImmutableMap.of();
}
}
代码示例来源: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.jira/jira-api
/**
* Convert the passed array into SharePermissions.
*
* @param array the JSON array to convert.
* @return the converted SharePermission.
* @throws JSONException if an error occurs during convertion.
*/
public static SharePermissions fromJsonArray(final JSONArray array) throws JSONException
{
notNull("array", array);
final Set<SharePermission> permissions = new HashSet<SharePermission>(array.length());
for (int i = 0; i < array.length(); i++)
{
permissions.add(SharePermissionUtils.fromJsonObject(array.getJSONObject(i)));
}
return new SharePermissions(permissions);
}
代码示例来源: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.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.atlassian.plugin.deflection/deflection-cse
JSONObject result = jsonResults.getJSONObject(i);
cseResults.add(new DefaultSearchResult(result.getString(RESULT_CONTENT),
result.getString(RESULT_URL),
代码示例来源: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
JSONObject result = jsonResults.getJSONObject(i);
代码示例来源:origin: com.marvelution.jira.plugins/jira-jenkins-plugin
JSONArray causes = object.optJSONArray("causes");
for (int ii = 0; ii < causes.length(); ii++) {
final JSONObject cause = causes.getJSONObject(ii);
if (cause.has("shortDescription")) {
if (artifacts != null && artifacts.length() > 0) {
for (int index = 0; index < artifacts.length(); index++) {
final JSONObject artifact = artifacts.getJSONObject(index);
build.getArtifacts().add(new Artifact(artifact.getString("fileName"),
artifact.getString("displayPath"), artifact.getString("relativePath")));
if (culprits != null && culprits.length() > 0) {
for (int index = 0; index < culprits.length(); index++) {
final JSONObject culprit = culprits.getJSONObject(index);
String id = optJsonString(culprit, "id");
if (id == null && culprit.has("absoluteUrl")) {
if (items != null && items.length() > 0) {
for (int index = 0; index < items.length(); index++) {
final JSONObject item = items.getJSONObject(index);
String commitId = String.valueOf(index);
for (String idField : COMMIT_ID_FIELDS) {
代码示例来源:origin: com.marvelution.jira.plugins/jira-jenkins-plugin
if (builds != null && builds.length() > 0) {
for (int index = 0; index < builds.length(); index++) {
final JSONObject jsonBuild = builds.getJSONObject(index);
final Build build = new Build(job.getId(), jsonBuild.getInt("number"));
job.getBuilds().add(build);
内容来源于网络,如有侵权,请联系作者删除!