net.sf.json.JSONArray.toString()方法的使用及代码示例

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

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

JSONArray.toString介绍

暂无

代码示例

代码示例来源:origin: jenkinsci/configuration-as-code-plugin

public FormValidation doCheckNewSource(@QueryParameter String newSource){
  Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
  String normalized = Util.fixEmptyAndTrim(newSource);
  File f = new File(newSource);
  if (normalized == null) {
    return FormValidation.ok(); // empty, do nothing
  } else if (!f.exists() && !ConfigurationAsCode.isSupportedURI(normalized)) {
    return FormValidation.error("Configuration cannot be applied. File or URL cannot be parsed or do not exist.");
  }
  try {
    final Map<Source, String> issues = collectIssues(newSource);
    final JSONArray errors = collectProblems(issues, "error");
    if (!errors.isEmpty()) {
      return FormValidation.error(errors.toString());
    }
    final JSONArray warnings = collectProblems(issues, "warning");
    if (!warnings.isEmpty()) {
      return FormValidation.warning(warnings.toString());
    }
    return FormValidation.okWithMarkup("The configuration can be applied");
  } catch (ConfiguratorException e) {
    return FormValidation.error(e, e.getCause().getMessage());
  } catch (IllegalArgumentException e) {
    return FormValidation.error(e, e.getCause().getMessage());
  }
}

代码示例来源:origin: jenkinsci/jenkins

JSONArray pluginCategories = JSONArray.fromObject(getPlatformPluginList().toString());
for (Iterator<?> categoryIterator = pluginCategories.iterator(); categoryIterator.hasNext();) {
  Object category = categoryIterator.next();

代码示例来源:origin: geoserver/geoserver

/**
   * @param list the list of layer identifiers to serialize
   * @return {@code null} if {@code list} is null, empty or contains only null objects; the JSON
   *     array representation of {@code list} otherwise, with any null element stripped off.
   */
  public static String toString(List<AuthorityURLInfo> obj) {
    if (obj == null || obj.isEmpty()) {
      return null;
    }
    JSONArray array = new JSONArray();

    for (AuthorityURLInfo auth : obj) {
      if (auth == null) {
        continue;
      }
      JSONObject jsonAuth = new JSONObject();
      jsonAuth.put(NAME, auth.getName());
      jsonAuth.put(HREF, auth.getHref());
      array.add(jsonAuth);
    }

    if (array.size() == 0) {
      // list was made of only null objects?
      return null;
    }

    String serialized = array.toString();
    return serialized;
  }
}

代码示例来源:origin: geoserver/geoserver

/**
   * @param list the list of auth urls to serialize
   * @return {@code null} if {@code list} is null, empty, or contains only null objects; the JSON
   *     array representation of {@code list} otherwise, with any null element stripped off.
   */
  public static String toString(List<LayerIdentifierInfo> list) {
    if (list == null || list.isEmpty()) {
      return null;
    }
    JSONArray array = new JSONArray();

    for (LayerIdentifierInfo id : list) {
      if (id == null) {
        continue;
      }
      JSONObject jsonId = new JSONObject();
      jsonId.put(AUTHORITY, id.getAuthority());
      jsonId.put(IDENTIFIER, id.getIdentifier());
      array.add(jsonId);
    }

    if (array.size() == 0) {
      // list was made of only null objects?
      return null;
    }
    String serialized = array.toString();
    return serialized;
  }
}

代码示例来源:origin: com.aliyun.openservices/aliyun-log

/**
 * return privilege in json string
 * 
 * @return privilege in json string
 */
public String ToJsonString() {
  return ToJsonArray().toString();
}

代码示例来源:origin: org.nuxeo.ecm.platform/nuxeo-platform-ui-select2

public String resolveMultipleDirectoryEntries(final Object value, final String directoryName,
    final boolean localize, String keySeparator, final boolean dbl10n, final String labelFieldName) {
  JSONArray result = getMultipleDirectoryEntries(value, directoryName, localize, keySeparator, dbl10n,
      labelFieldName);
  if (result != null) {
    return result.toString();
  } else {
    return "[]";
  }
}

代码示例来源:origin: tangyanbo/springmore

/**
 * 数组,集合等转json
 * @param bean
 * @param jsonConfig
 * @return
 * @author 唐延波
 * @date 2015年7月6日
 */
private String arrayToJson(Object bean){
  JSONArray jsonArray = JSONArray.fromObject(bean, jsonConfig);
  return jsonArray.toString();		
}

代码示例来源:origin: com.blazemeter/blazemeter-api-client

protected BuildResult notifyAboutErrors(JSONArray errors) {
  notifier.notifyWarning("Having errors " + errors.toString());
  logger.error("Having errors " + errors.toString());
  return isErrorsFailed(errors) ? BuildResult.FAILED : BuildResult.ERROR;
}

代码示例来源:origin: fluxtream/fluxtream-app

public static <T> List<T> cast(String result, Class<T> clazz, Type listType) {
  JSONObject resultsJson = JSONObject.fromObject(result);
  final JSONArray results = resultsJson.getJSONArray("results");
  List<T> items = gson.fromJson(results.toString(), listType);
  return items;
}

代码示例来源:origin: com.aliyun.openservices/aliyun-log

public String GetRequestBody()
  {
    JSONArray array = new JSONArray();
    array.addAll(shards);
    return array.toString();
  }
}

代码示例来源:origin: kg.apc/jmeter-plugins-standard

public void sendOnlineData(JSONArray data) throws IOException {
  String uri = address + "api/active/receiver/data/";
  LinkedList<Part> partsList = new LinkedList<>();
  String dataStr = data.toString();
  log.debug("Sending active test data: " + dataStr);
  partsList.add(new StringPart("data", dataStr));
  multipartPost(partsList, uri, HttpStatus.SC_ACCEPTED);
}

代码示例来源:origin: kg.apc/jmeter-plugins-extras-libs

private String formatJSON(String json) {
  if (json.startsWith("[") && json.endsWith("]")) {
    return JSONArray.fromObject(json).toString(4);
  } else {
    return JSONObject.fromObject(json).toString(4);
  }
}

代码示例来源:origin: pl.edu.icm.sedno/sedno-tools

public String toJsonArray(Object[] values) {
   if (values == null)
     return null;
   
   JSONArray list = new JSONArray();
   
   for (Object v : values){
     list.add(v);
   }
   String json = list.toString();
   
   return json;
}

代码示例来源:origin: com.aliyun.openservices/aliyun-log

protected void ExtractShards(JSONArray array, String requestId,
    ArrayList<Integer> shards) throws LogException {
  try {
    for (int i = 0; i < array.size(); i++) {
      shards.add(array.getInt(i));
    }
  } catch (JSONException e) {
    throw new LogException(ErrorCodes.BAD_RESPONSE,
        "The response is not valid shard json array string : "
            + array.toString(), e, requestId);
  }
}

代码示例来源:origin: aliyun/aliyun-log-java-sdk

protected void ExtractShards(JSONArray array, String requestId,
    ArrayList<Integer> shards) throws LogException {
  try {
    for (int i = 0; i < array.size(); i++) {
      shards.add(array.getInt(i));
    }
  } catch (JSONException e) {
    throw new LogException(ErrorCodes.BAD_RESPONSE,
        "The response is not valid shard json array string : "
            + array.toString(), e, requestId);
  }
}

代码示例来源:origin: org.apache.struts/struts2-rest-plugin

public String fromObject(ActionInvocation invocation, Object obj, String resultCode, Writer stream) throws IOException {
  if (obj != null) {
    if (isArray(obj)) {
      JSONArray jsonArray = JSONArray.fromObject(obj);
      stream.write(jsonArray.toString());
    } else {
      JSONObject jsonObject = JSONObject.fromObject(obj);
      stream.write(jsonObject.toString());
    }
  }
  return null;
}

代码示例来源:origin: com.blazemeter/blazemeter-api-client

protected BuildResult notifyAboutFailed(JSONArray failures) {
  notifier.notifyInfo("Having failures " + failures.toString());
  notifier.notifyInfo("Setting ci-status = " + BuildResult.FAILED.name());
  return BuildResult.FAILED;
}

代码示例来源:origin: Blazemeter/jmeter-bzm-plugins

public void sendOnlineData(JSONArray data) throws IOException {
  String uri = address + "api/active/receiver/data";
  LinkedList<FormBodyPart> partsList = new LinkedList<>();
  String dataStr = data.toString();
  log.debug("Sending active test data: " + dataStr);
  partsList.add(new FormBodyPart("data", new StringBody(dataStr)));
  query(createPost(uri, partsList), 202);
}

代码示例来源:origin: org.nuxeo.ecm.webengine/nuxeo-webengine-ui

public String getTreeAsJSONArray(WebContext ctx) {
  JSonTreeSerializer serializer = getSerializer(ctx);
  JSONObject o = serializer.toJSON(tree.root);
  JSONArray array = new JSONArray();
  array.add(o);
  return array.toString();
}

代码示例来源:origin: opentoutatice-ecm.platform/opentoutatice-ecm-platform-automation

/**
 * @return searchOverflowMessage
 * @since 5.7.3
 */
private Blob searchOverflowMessage() {
  JSONArray result = new JSONArray();
  JSONObject obj = new JSONObject();
  obj.put(Select2Common.LABEL, I18NUtils.getMessageString("messages", "label.security.searchOverFlow", new Object[0], getLocale()));
  result.add(obj);
  return new StringBlob(result.toString(), "application/json");
}

相关文章