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

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

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

JSONArray.toCollection介绍

暂无

代码示例

代码示例来源:origin: RPTools/maptool

private List<Map<String, Integer>> convertJSONStringToList(final String pointsString) {
  Object jsonObject = JSONMacroFunctions.asJSON(pointsString);
  ArrayList<Map<String, Integer>> pathPoints = new ArrayList<Map<String, Integer>>();
  if (jsonObject instanceof JSONArray) {
    ArrayList<?> tempPoints = (ArrayList<?>) JSONArray.toCollection((JSONArray) jsonObject);
    for (Object o : tempPoints) {
      MorphDynaBean bean = (MorphDynaBean) o;
      Map<String, Integer> point = new HashMap<String, Integer>();
      point.put("x", (Integer) bean.get("x"));
      point.put("y", (Integer) bean.get("y"));
      pathPoints.add(point);
    }
  }
  return pathPoints;
}

代码示例来源:origin: org.onehippo.cms7/hippo-repository-provider

public ParsedFacet(String namespacedFacetConfig) throws Exception {
  //in this case, the facetNameConfig is already namespaced
  displayFacetName = namespacedFacetConfig;
  boolean mapped = false;
  // jcrPropertyName is format: prefix:localname
  this.namespacedProperty = namespacedFacetConfig;
  if (namespacedFacetConfig.indexOf("$[") > -1) {
    try {
      rangeConfig = namespacedFacetConfig.substring(namespacedFacetConfig.indexOf("$[") + 1);
      JSONArray jsonArray = JSONArray.fromObject(rangeConfig);
      facetRanges = (List<FacetRange>) JSONArray.toCollection(jsonArray, FacetRange.class);
      this.namespacedProperty = namespacedFacetConfig.substring(0, namespacedFacetConfig.indexOf("$["));
      if (!mapped) {
        displayFacetName = this.namespacedProperty;
      }
    } catch (Exception e) {
      throw new Exception("Malformed facet range configuration '" + namespacedFacetConfig + "'", e);
    }
  }
  if (facetRanges != null) {
    for (FacetRange range : facetRanges) {
      range.setNamespacedProperty(namespacedProperty);
    }
  }
}

代码示例来源:origin: RPTools/maptool

private List<Map<String, Integer>> crossedToken(final Zone zone, final Token tokenInContext, final Token target, final String pathString) {
  Object jsonObject = JSONMacroFunctions.asJSON(pathString);
  ArrayList<Map<String, Integer>> pathPoints = new ArrayList<Map<String, Integer>>();
  if (jsonObject instanceof JSONArray) {
    ArrayList<?> tempPoints = (ArrayList<?>) JSONArray.toCollection((JSONArray) jsonObject);
    for (Object o : tempPoints) {
      MorphDynaBean bean = (MorphDynaBean) o;
      //System.out.println(bean.get("x"));
      Map<String, Integer> point = new HashMap<String, Integer>();
      point.put("x", (Integer) bean.get("x"));
      point.put("y", (Integer) bean.get("y"));
      pathPoints.add(point);
    }
    return getInstance().crossedToken(zone, tokenInContext, target, pathPoints);
  }
  return pathPoints;
}

代码示例来源:origin: org.onehippo.cms7/hippo-repository-provider

rangeConfig = facetNameConfig.substring(facetNameConfig.indexOf("$[") + 1);
JSONArray jsonArray = JSONArray.fromObject(rangeConfig);
facetRanges = (List<FacetRange>) JSONArray.toCollection(jsonArray, FacetRange.class);
jcrPropertyName = facetNameConfig.substring(0, facetNameConfig.indexOf("$["));
if (!mapped) {

代码示例来源:origin: org.phenotips/medsavant-client-api

@SuppressWarnings("unchecked")
private Collection<Integer> getReferenceIDs()
{
  HttpPost method = null;
  try {
    String url = getMethodURL(PROJECT_MANAGER, "getReferenceIDsForProject");
    method = new HttpPost(url);
    JSONArray parameters = new JSONArray();
    parameters.add(this.projectID);
    String body = REQUEST_PARAMETER + URLEncoder.encode(parameters.toString(), ENCODING);
    method.setEntity(new StringEntity(body, REQUEST_CONTENT_TYPE));
    try (CloseableHttpResponse httpResponse = this.client.execute(method)) {
      String response = IOUtils.toString(httpResponse.getEntity().getContent(), Consts.UTF_8);
      JSONArray ids = (JSONArray) JSONSerializer.toJSON(response);
      JsonConfig config = new JsonConfig();
      config.setCollectionType(Set.class);
      return JSONArray.toCollection(ids, config);
    }
  } catch (Exception ex) {
    this.logger.warn("Failed to get the reference IDs: {}", ex.getMessage(), ex);
  } finally {
    if (method != null) {
      method.releaseConnection();
    }
  }
  return Collections.emptySet();
}

代码示例来源:origin: bioinformatics-ua/dicoogle

if (qp != null) {
  this.selectedProviders = new ArrayList<>();
  this.selectedProviders.addAll(JSONArray.toCollection(arr,
      String.class));
} else {

代码示例来源:origin: RPTools/maptool

} else {
  @SuppressWarnings("unchecked")
  Collection<String> targets = JSONArray.toCollection(jarray, List.class); // Returns an ArrayList<String>
  MapTool.addGlobalMessage(message, (List<String>) targets);

代码示例来源:origin: org.nuxeo.ecm.platform/nuxeo-platform-contentview-jsf

queryParams.add(null);
} else if (item instanceof JSONArray) {
  queryParams.add(JSONArray.toCollection((JSONArray) item));
} else {
  queryParams.add(item);

相关文章