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

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

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

JSONArray.toString介绍

[英]Make a JSON text of this JSONArray. For compactness, no unnecessary whitespace is added. If it is not possible to produce a syntactically correct JSON text then null will be returned instead. This could occur if the array contains an invalid number.

Warning: This method assumes that the data structure is acyclical.
[中]制作此JSONArray的JSON文本。为了紧凑,没有添加不必要的空白。如果无法生成语法正确的JSON文本,则将返回null。如果数组包含无效数字,则可能发生这种情况。
警告:此方法假定数据结构是非循环的。

代码示例

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

/**
 * Make a prettyprinted JSON text of this JSONArray.
 * Warning: This method assumes that the data structure is acyclical.
 *
 * @param indentFactor The number of spaces to add to each level of
 *                     indentation.
 * @return a printable, displayable, transmittable
 *         representation of the object, beginning
 *         with <code>[</code>&nbsp;<small>(left bracket)</small> and ending
 *         with <code>]</code>&nbsp;<small>(right bracket)</small>.
 * @throws JSONException if JSON object fails to convert to String
 */
public String toString(final int indentFactor) throws JSONException
{
  return toString(indentFactor, 0);
}

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

@Override
public String failureReason()
{
  if (failureReasons.isEmpty())
  {
    return null;
  }
  if (failureReasons.size() == 1)
  {
    return failureReasons.get(0);
  }
  return new JSONArray(failureReasons).toString();
}

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

public String getEffectiveApplicationsJson()
{
  return new JSONArray(effectiveApplications.stream().map(EffectiveApplication::getKey).collect(CollectorsUtil.toImmutableSet())).toString();
}

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

public String getJsonString()
{
  final List<SharePermission> sortedShares = new ArrayList<SharePermission>(getSharePermissions());
  Collections.sort(sortedShares, shareTypeFactory.getPermissionComparator());
  try
  {
    return SharePermissionUtils.toJsonArray(sortedShares).toString();
  }
  catch (final JSONException e)
  {
    log.error("Unable to create JSON representation of shares: " + e.getMessage(), e);
    return "";
  }
}

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

public String getJsonString()
{
  final List<SharePermission> sortedShares = new ArrayList<SharePermission>(getPermissions().getPermissionSet());
  Collections.sort(sortedShares, shareTypeFactory.getPermissionComparator());
  try
  {
    return SharePermissionUtils.toJsonArray(sortedShares).toString();
  }
  catch (final JSONException e)
  {
    log.error("Unable to create JSON representation of shares: " + e.getMessage(), e);
    return "";
  }
}

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

/**
   * Returns the content of the DarkFeatures &lt;meta&gt; tag. This will be a JSON array literal,
   * e.g. <code>[ "feat1", "feat2" ]</code>.
   *
   * @return a String containing a Javscript array literal with the enabled dark feature names
   */
  String getContent()
  {
    Set<String> keys = featureManager.getDarkFeatures().getAllEnabledFeatures();

    return new JSONArray(keys).toString();
  }
}

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

public String getJqlReservedWordsJson() throws JSONException
{
  final Set<String> reservedWords = jqlStringSupport.getJqlReservedWords();
  JSONArray results = new JSONArray();
  for (String reservedWord : reservedWords)
  {
    results.put(reservedWord);
  }
  return results.toString();
}

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

public String getJsonString()
{
  final List<SharePermission> sortedShares = new ArrayList<SharePermission>(getPermissions().getPermissionSet());
  Collections.sort(sortedShares, shareTypeFactory.getPermissionComparator());
  try
  {
    return SharePermissionUtils.toJsonArray(sortedShares).toString();
  }
  catch (final JSONException e)
  {
    log.error("Unable to create JSON representation of shares: " + e.getMessage(), e);
    return "";
  }
}

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

public String getJsonString()
  {
    final List<SharePermission> sortedShares = new ArrayList<SharePermission>(getPermissions().getPermissionSet());
    Collections.sort(sortedShares, shareTypeFactory.getPermissionComparator());
    try
    {
      return SharePermissionUtils.toJsonArray(sortedShares).toString();
    }
    catch (final JSONException e)
    {
      log.error("Unable to create JSON representation of shares: " + e.getMessage(), e);
      return "";
    }
  }
}

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

private Option<String> generateArchiveFileIndex(final @Nonnull File file, final @Nonnull Attachment attachment)
{
  final Iterable<AttachmentProcessorModuleDescriptor> filteredProcessors = filterProcessors(attachment);
  if (Iterables.isEmpty(filteredProcessors))
  {
    return Option.none();
  }
  final AttachmentProcessorModuleDescriptor firstDescriptor = filteredProcessors.iterator().next();
  final List<AttachmentArchiveEntry> entries = firstDescriptor.getModule().processAttachment(file);
  final Iterable<JSONObject> jsons = AttachmentArchiveImpl.serialize(entries);
  final JSONArray array = new JSONArray(Lists.newArrayList(
      Iterables.filter(jsons, new TotalLengthPredicate(EntityConstants.EXTREMELY_LONG_MAXIMUM_LENGTH))));
  return Option.some(array.toString());
}

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

return ((JSONArray) value).toString(indentFactor, indent);
return result.toString(indentFactor, indent);
return new JSONArray(value).toString(indentFactor, indent);

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

return jsonArray.toString();

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

public String getShareTypeEditor(final JiraAuthenticationContext authenticationContext)
{
  Assertions.notNull("authenticationContext", authenticationContext);
  final Map<String, Object> params = new HashMap<String, Object>();
  final Collection<Project> projects = getProjects(authenticationContext.getUser());
  final Set<ProjectRole> roles = new HashSet<ProjectRole>();
  final Map<Long, String> rolesMap = new HashMap<Long, String>();
  for (final Project project : projects)
  {
    final JSONArray array = new JSONArray();
    Collection<ProjectRole> projectRoles = projectRoleManager.getProjectRoles(authenticationContext.getUser(), project);
    roles.addAll(projectRoles);
    projectRoles = sort(projectRoles, ProjectRoleComparator.COMPARATOR);
    for (final Object element : projectRoles)
    {
      final ProjectRole role = (ProjectRole) element;
      array.put(role.getId());
    }
    rolesMap.put(project.getId(), array.toString());
  }
  params.put(ProjectShareTypeRenderer.PROJECTS_KEY, sort(projects, ProjectNameComparator.COMPARATOR));
  params.put(ProjectShareTypeRenderer.ROLES_KEY, sort(roles, ProjectRoleComparator.COMPARATOR));
  params.put(ProjectShareTypeRenderer.ROLES_MAP, rolesMap);
  return renderVelocity("share-type-project-selector.vm", params, authenticationContext);
}

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

return result.toString();
return new JSONArray(value).toString();

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

/**
 * Returns a json string of [ {name: groupName}, ... ]
 */
private String getGroupsAsJsonString(final Collection<Group> groups)
{
  JSONArray root = new JSONArray();
  for (Group group : groups)
  {
    JSONObject groupJson = new JSONObject();
    try
    {
      groupJson.put("name", group.getName());
    }
    catch (JSONException e)
    {
      log.warn("skipping project role object that could not converted to json: " + group.getName() + " - " + e.getMessage());
    }
    root.put(groupJson);
  }
  return root.toString();
}

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

return results.toString();

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

/**
   * Returns a json string of [ {id: 1, name: groupName, description: desc}, ... ]
   */
  private String getProjectRolesAsJsonString(final Collection<ProjectRole> projectRoles)
  {
    JSONArray root = new JSONArray();
    for (ProjectRole projectRole : projectRoles)
    {
      JSONObject role = new JSONObject();
      try
      {
        role.put("id", projectRole.getId());
        role.put("name", projectRole.getName());
        role.put("description", projectRole.getDescription());
      }
      catch (JSONException e)
      {
        log.warn("skipping project role object that could not converted to json: " + projectRole + " - " + e.getMessage());
      }
      root.put(role);
    }
    return root.toString();
  }
}

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

return results.toString();

相关文章