javax.json.JsonArray.getJsonArray()方法的使用及代码示例

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

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

JsonArray.getJsonArray介绍

暂无

代码示例

代码示例来源:origin: org.diirt/vtype-json

public List<Object> getColumnValues(String string, List<Class<?>> types) {
  JsonArray array = getJsonArray(string);
  List<Object> result = new ArrayList<>();
  for (int i = 0; i < types.size(); i++) {
    Class<?> type = types.get(i);
    if (String.class.equals(type)) {
      result.add(toListString(array.getJsonArray(i)));
    } else if (double.class.equals(type)) {
      result.add(toListDouble(array.getJsonArray(i)));
    } else if (float.class.equals(type)) {
      result.add(toListFloat(array.getJsonArray(i)));
    } else if (long.class.equals(type)) {
      result.add(toListLong(array.getJsonArray(i)));
    } else if (int.class.equals(type)) {
      result.add(toListInt(array.getJsonArray(i)));
    } else if (short.class.equals(type)) {
      result.add(toListShort(array.getJsonArray(i)));
    } else if (byte.class.equals(type)) {
      result.add(toListByte(array.getJsonArray(i)));
    } else if (Instant.class.equals(type)) {
      result.add(toListTimestamp(array.getJsonArray(i)));
    } else {
      throw new IllegalArgumentException("Column type " + type + " not supported");
    }
  }
  return result;
}

代码示例来源:origin: org.epics/vtype-json

public List<Object> getColumnValues(String string, List<Class<?>> types) {
  JsonArray array = getJsonArray(string);
  List<Object> result = new ArrayList<>();
  for (int i = 0; i < types.size(); i++) {
    Class<?> type = types.get(i);
    if (String.class.equals(type)) {
      result.add(toListString(array.getJsonArray(i)));
    } else if (double.class.equals(type)) {
      result.add(toListDouble(array.getJsonArray(i)));
    } else if (float.class.equals(type)) {
      result.add(toListFloat(array.getJsonArray(i)));
    } else if (long.class.equals(type)) {
      result.add(toListLong(array.getJsonArray(i)));
    } else if (int.class.equals(type)) {
      result.add(toListInt(array.getJsonArray(i)));
    } else if (short.class.equals(type)) {
      result.add(toListShort(array.getJsonArray(i)));
    } else if (byte.class.equals(type)) {
      result.add(toListByte(array.getJsonArray(i)));
    } else if (Timestamp.class.equals(type)) {
      result.add(toListTimestamp(array.getJsonArray(i)));
    } else {
      throw new IllegalArgumentException("Column type " + type + " not supported");
    }
  }
  return result;
}

代码示例来源:origin: hopshadoop/hopsworks

public List<NodesTableItem> getNdbinfoNodesTable(String hostAddress,
  String agentPassword) throws AppException {
 List<NodesTableItem> resultList = new ArrayList<NodesTableItem>();
 String url = createUrl("mysql", hostAddress, "ndbinfo", "nodes");
 String jsonString = fetchContent(url, agentPassword);
 InputStream stream = new ByteArrayInputStream(jsonString.getBytes(          StandardCharsets.UTF_8));
 try {
  JsonArray json = Json.createReader(stream).readArray();
  if (json.get(0).equals("Error")) {
   resultList.add(new NodesTableItem(null, json.getString(1), null, null,
       null));
   return resultList;
  }
  for (int i = 0; i < json.size(); i++) {
   JsonArray node = json.getJsonArray(i);
   Integer nodeId = node.getInt(0);
   Long uptime = node.getJsonNumber(1).longValue();
   String status = node.getString(2);
   Integer startPhase = node.getInt(3);
   Integer configGeneration = node.getInt(4);
   resultList.add(new NodesTableItem(nodeId, status, uptime, startPhase,
       configGeneration));
  }
 } catch (Exception ex) {
  logger.log(Level.SEVERE, "Exception: {0}", ex);
  resultList.add(new NodesTableItem(null, "Error", null, null, null));
 }
 return resultList;
}

相关文章