org.codehaus.jettison.json.JSONArray.getString()方法的使用及代码示例

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

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

JSONArray.getString介绍

[英]Get the string associated with an index.
[中]获取与索引关联的字符串。

代码示例

代码示例来源:origin: org.codehaus.jettison/jettison

@SuppressWarnings("unused")
private void readAttribute( Node n, String k, JSONArray array ) throws JSONException {
  for (int i = 0; i < array.length(); i++) {
    readAttribute( n, k, array.getString( i ) );
  }
}

代码示例来源:origin: org.codehaus.jettison/jettison

/**
 * Produce a JSONArray containing the values of the members of this
 * JSONObject.
 * @param names A JSONArray containing a list of key strings. This
 * determines the sequence of the values in the result.
 * @return A JSONArray of values.
 * @throws JSONException If any of the values are non-finite numbers.
 */
public JSONArray toJSONArray(JSONArray names) throws JSONException {
  if (names == null || names.length() == 0) {
    return null;
  }
  JSONArray ja = new JSONArray();
  for (int i = 0; i < names.length(); i += 1) {
    ja.put(this.opt(names.getString(i)));
  }
  return ja;
}

代码示例来源:origin: org.codehaus.jettison/jettison

/**
 * Produce a JSONObject by combining a JSONArray of names with the values
 * of this JSONArray.
 * @param names A JSONArray containing a list of key strings. These will be
 * paired with the values.
 * @return A JSONObject, or null if there are no names or if this JSONArray
 * has no values.
 * @throws JSONException If any of the names are null.
 */
public JSONObject toJSONObject(JSONArray names) throws JSONException {
  if (names == null || names.length() == 0 || length() == 0) {
    return null;
  }
  JSONObject jo = new JSONObject();
  for (int i = 0; i < names.length(); i += 1) {
    jo.put(names.getString(i), this.opt(i));
  }
  return jo;
}

代码示例来源:origin: apache/incubator-atlas

public static String toString(JSONArray jsonArray) throws JSONException {
  ArrayList<String> resultsList = new ArrayList<>();
  for (int index = 0; index < jsonArray.length(); index++) {
    resultsList.add(jsonArray.getString(index));
  }
  return StringUtils.join(resultsList, ",");
}

代码示例来源:origin: org.apache.apex/malhar-library

@Override
public void setFieldFromJSON(GPOMutable gpo, String field, JSONArray jo, int index)
{
 String val;
 try {
  val = jo.getString(index);
 } catch (JSONException ex) {
  throw new IllegalArgumentException("The key " + field + " does not have a valid string value.", ex);
 }
 gpo.setField(field, val);
}

代码示例来源:origin: org.openengsb.wrapped/jira-rest-java-client-core

public static Collection<String> toStringCollection(final JSONArray jsonArray) throws JSONException {
  final ArrayList<String> res = new ArrayList<String>(jsonArray.length());
  for (int i = 0; i < jsonArray.length(); i++) {
    res.add(jsonArray.getString(i));
  }
  return res;
}

代码示例来源:origin: com.atlassian.jira/jira-rest-java-client-p3

private Set<StandardOperation> parseOperations(JSONArray operations) throws JSONException {
  int operationsCount = operations.length();
  final Set<StandardOperation> res = Sets.newHashSetWithExpectedSize(operationsCount);
  for (int i = 0; i < operationsCount; i++) {
    String opName = operations.getString(i);
    StandardOperation op = StandardOperation.valueOf(opName.toUpperCase());
    res.add(op);
  }
  return res;
}

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

private Set<StandardOperation> parseOperations(JSONArray operations) throws JSONException {
  final int operationsCount = operations.length();
  final Set<StandardOperation> res = Sets.newHashSetWithExpectedSize(operationsCount);
  for (int i = 0; i < operationsCount; i++) {
    String opName = operations.getString(i);
    StandardOperation op = StandardOperation.valueOf(opName.toUpperCase());
    res.add(op);
  }
  return res;
}

代码示例来源:origin: com.atlassian.jira/jira-rest-java-client

private Set<StandardOperation> parseOperations(JSONArray operations) throws JSONException {
  int operationsCount = operations.length();
  final Set<StandardOperation> res = Sets.newHashSetWithExpectedSize(operationsCount);
  for (int i = 0; i < operationsCount; i++) {
    String opName = operations.getString(i);
    StandardOperation op = StandardOperation.valueOf(opName.toUpperCase());
    res.add(op);
  }
  return res;
}

代码示例来源:origin: org.openengsb.wrapped/jira-rest-java-client-core

private Set<StandardOperation> parseOperations(JSONArray operations) throws JSONException {
  final int operationsCount = operations.length();
  final Set<StandardOperation> res = Sets.newHashSetWithExpectedSize(operationsCount);
  for (int i = 0; i < operationsCount; i++) {
    String opName = operations.getString(i);
    StandardOperation op = StandardOperation.valueOf(opName.toUpperCase());
    res.add(op);
  }
  return res;
}

代码示例来源:origin: org.openengsb.wrapped/jira-rest-java-client-core

public static Map<String, String> toStringMap(final JSONArray names, final JSONObject values) throws JSONException {
    final Map<String, String> result = Maps.newHashMap();
    for (int i = 0; i < names.length(); i++) {
      final String key = names.getString(i);
      result.put(key, values.getString(key));
    }
    return result;
  }
}

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

public static Collection<String> toStringCollection(final JSONArray jsonArray) throws JSONException {
  final ArrayList<String> res = new ArrayList<String>(jsonArray.length());
  for (int i = 0; i < jsonArray.length(); i++) {
    res.add(jsonArray.getString(i));
  }
  return res;
}

代码示例来源:origin: com.atlassian.jira/jira-rest-java-client-p3

public static Collection<String> toStringCollection(JSONArray jsonArray) throws JSONException {
  final ArrayList<String> res = new ArrayList<String>(jsonArray.length());
  for (int i = 0; i < jsonArray.length(); i++) {
    res.add(jsonArray.getString(i));
  }
  return res;
}

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

public static Map<String, String> toStringMap(final JSONArray names, final JSONObject values) throws JSONException {
    final Map<String, String> result = Maps.newHashMap();
    for (int i = 0; i < names.length(); i++) {
      final String key = names.getString(i);
      result.put(key, values.getString(key));
    }
    return result;
  }
}

代码示例来源:origin: com.atlassian.jira/jira-rest-java-client

public static Collection<String> toStringCollection(JSONArray jsonArray) throws JSONException {
  final ArrayList<String> res = new ArrayList<String>(jsonArray.length());
  for (int i = 0; i < jsonArray.length(); i++) {
    res.add(jsonArray.getString(i));
  }
  return res;
}

代码示例来源:origin: hadooparchitecturebook/hadoop-arch-book

public ValidationRules(JSONObject jsonObject)  throws JSONException {
 if (jsonObject != null) {
  JSONArray jsonArray = jsonObject.getJSONArray("bannedVanderIds");
  for (int i = 0; i < jsonArray.length(); i++) {
   String bannedId = jsonArray.getString(i);
   LOG.info(" - Adding bannded venderId:" + bannedId);
   bannedVanderIdSet.add(bannedId);
  }
  thresholdInSpendDifferenceFromTodayFromPastMonthAverage = jsonObject.getDouble("thresholdInSpendDifferenceFromTodayFromPastMonthAverage");
 } else {
  LOG.warn("No Validation Rules Found in HBase");
 }
}

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

private void initVpcOptions(JSONObject vpcOptions) throws JSONException {
 _vpcId = vpcOptions.getString(JSON_KEY_ES_VPC_ID);
 JSONArray securityGroupIds = vpcOptions.getJSONArray(JSON_KEY_SECURITY_GROUP_IDS);
 for (int i = 0; i < securityGroupIds.length(); i++) {
  _securityGroups.add(securityGroupIds.getString(i));
 }
 JSONArray subnetIds = vpcOptions.getJSONArray(JSON_KEY_SUBNET_IDS);
 for (int i = 0; i < subnetIds.length(); i++) {
  _subnets.add(subnetIds.getString(i));
 }
}

代码示例来源:origin: org.codehaus.jettison/com.springsource.org.codehaus.jettison

private void readAttribute(Node n, String k, JSONArray array) throws JSONException {
  for (int i = 0; i < array.length(); i++) {
    readAttribute(n, k, array.getString(i));
  }
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

private void verifyAccesibleNodeLabels(JSONObject queueJson,
  Set<String> accesibleNodeLabels) throws JSONException {
 JSONArray nodeLabels = queueJson.getJSONArray("nodeLabels");
 assertEquals("number of accessible Node Labels not matching",
   accesibleNodeLabels.size(), nodeLabels.length());
 for (int i = 0; i < nodeLabels.length(); i++) {
  assertTrue("Invalid accessible node label : " + nodeLabels.getString(i),
    accesibleNodeLabels.contains(nodeLabels.getString(i)));
 }
}

代码示例来源:origin: org.apache.hadoop/hadoop-mapreduce-client-app

public void verifyBlacklistedNodesInfo(JSONObject blacklist, AppContext ctx)
 throws JSONException, Exception{
 JSONArray array = blacklist.getJSONArray("blacklistedNodes");
 assertEquals(array.length(), ctx.getBlacklistedNodes().size());
 for (int i = 0; i < array.length(); i++) {
  assertTrue(ctx.getBlacklistedNodes().contains(array.getString(i)));
 }
}

相关文章