org.json.simple.JSONObject.values()方法的使用及代码示例

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

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

JSONObject.values介绍

暂无

代码示例

代码示例来源:origin: ethereum/ethereumj

@Test
public void testPremineFromJSON() throws ParseException {
  JSONParser parser = new JSONParser();
  JSONObject genesisMap = (JSONObject) parser.parse(TEST_GENESIS);
  Set keys = genesisMap.keySet();
  Trie state = new SecureTrie((byte[]) null);
  for (Object key : keys) {
    JSONObject val = (JSONObject) genesisMap.get(key);
    String denom = (String) val.keySet().toArray()[0];
    String value = (String) val.values().toArray()[0];
    BigInteger wei = Denomination.valueOf(denom.toUpperCase()).value().multiply(new BigInteger(value));
    AccountState acctState = new AccountState(BigInteger.ZERO, wei);
    state.put(Hex.decode(key.toString()), acctState.getEncoded());
  }
  logger.info("root: " + Hex.toHexString(state.getRootHash()));
  assertEquals(GENESIS_STATE_ROOT, Hex.toHexString(state.getRootHash()));
}

代码示例来源:origin: rhuss/jolokia

private Object navigatePath() {
    int size = pathStack.size();
    JSONObject innerMap = infoMap;

    while (size > 0) {
      Collection vals = innerMap.values();
      if (vals.size() == 0) {
        return innerMap;
      } else if (vals.size() != 1) {
        throw new IllegalStateException("Internal: More than one key found when extracting with path: " + vals);
      }
      Object value = vals.iterator().next();

      // End leaf, return it ....
      if (size == 1) {
        return value;
      }
      // Dive in deeper ...
      if (!(value instanceof JSONObject)) {
        throw new IllegalStateException("Internal: Value within path extraction must be a Map, not " + value.getClass());
      }
      innerMap = (JSONObject) value;
      --size;
    }
    return innerMap;
  }
}

代码示例来源:origin: rhuss/jolokia

private void putRowsToTabularData(TabularDataSupport pTabularData, JSONObject pValue, int pLevel) {
    TabularType type = pTabularData.getTabularType();
    for (Object value : pValue.values()) {
      if (!(value instanceof JSONObject)) {
        throw new IllegalArgumentException(
            "Cannot convert " + pValue + " to type " +
            type + " because the object values provided (" + value.getClass() + ") is not of the expected type JSONObject at level " + pLevel);
      }
      JSONObject jsonValue = (JSONObject) value;
      if (pLevel > 1) {
        putRowsToTabularData(pTabularData, jsonValue, pLevel - 1);
      } else {
        pTabularData.put((CompositeData) getDispatcher().convertToObject(type.getRowType(), jsonValue));
      }
    }
  }
}

代码示例来源:origin: io.fabric8.jube.images.fabric8/fabric8-mq

public static ObjectName getRoot(J4pClient client) throws Exception {
  String type = "org.apache.activemq:*,type=Broker";
  String attribute = "BrokerName";
  ObjectName objectName = new ObjectName(type);
  J4pResponse<J4pReadRequest> response = client.execute(new J4pReadRequest(objectName, attribute));
  JSONObject jsonObject = response.getValue();
  JSONObject nameObject = (JSONObject) jsonObject.values().iterator().next();
  String name = nameObject.values().iterator().next().toString();
  return new ObjectName("org.apache.activemq:type=Broker,brokerName=" + name);
}

代码示例来源:origin: io.fabric8.ipaas.apps/fabric8mq

public static ObjectName getRoot(J4pClient client) throws Exception {
  String type = "org.apache.activemq:*,type=Broker";
  String attribute = "BrokerName";
  ObjectName objectName = new ObjectName(type);
  J4pResponse<J4pReadRequest> response = client.execute(new J4pReadRequest(objectName, attribute));
  JSONObject jsonObject = response.getValue();
  JSONObject nameObject = (JSONObject) jsonObject.values().iterator().next();
  String name = nameObject.values().iterator().next().toString();
  return new ObjectName("org.apache.activemq:type=Broker,brokerName=" + name);
}

代码示例来源:origin: org.jolokia/jolokia-core

private Object navigatePath() {
    int size = pathStack.size();
    JSONObject innerMap = infoMap;

    while (size > 0) {
      Collection vals = innerMap.values();
      if (vals.size() == 0) {
        return innerMap;
      } else if (vals.size() != 1) {
        throw new IllegalStateException("Internal: More than one key found when extracting with path: " + vals);
      }
      Object value = vals.iterator().next();

      // End leaf, return it ....
      if (size == 1) {
        return value;
      }
      // Dive in deeper ...
      if (!(value instanceof JSONObject)) {
        throw new IllegalStateException("Internal: Value within path extraction must be a Map, not " + value.getClass());
      }
      innerMap = (JSONObject) value;
      --size;
    }
    return innerMap;
  }
}

代码示例来源:origin: org.jolokia/jolokia-osgi

private Object navigatePath() {
    int size = pathStack.size();
    JSONObject innerMap = infoMap;

    while (size > 0) {
      Collection vals = innerMap.values();
      if (vals.size() == 0) {
        return innerMap;
      } else if (vals.size() != 1) {
        throw new IllegalStateException("Internal: More than one key found when extracting with path: " + vals);
      }
      Object value = vals.iterator().next();

      // End leaf, return it ....
      if (size == 1) {
        return value;
      }
      // Dive in deeper ...
      if (!(value instanceof JSONObject)) {
        throw new IllegalStateException("Internal: Value within path extraction must be a Map, not " + value.getClass());
      }
      innerMap = (JSONObject) value;
      --size;
    }
    return innerMap;
  }
}

代码示例来源:origin: org.apache.camel/camel-commands-jolokia

JSONObject data = response.getValue();
if (data != null) {
  for (Object obj : data.values()) {
    JSONObject data2 = (JSONObject) obj;
    JSONObject service = (JSONObject) data2.values().iterator().next();

代码示例来源:origin: org.apache.camel/camel-commands-jolokia

@Override
public List<Map<String, Object>> browseInflightExchanges(String camelContextName, String route, int limit, boolean sortByLongestDuration) throws Exception {
  if (jolokia == null) {
    throw new IllegalStateException("Need to connect to remote jolokia first");
  }
  List<Map<String, Object>> answer = new ArrayList<>();
  ObjectName found = lookupCamelContext(camelContextName);
  if (found != null) {
    String pattern = String.format("%s:context=%s,type=services,name=DefaultInflightRepository", found.getDomain(), found.getKeyProperty("context"));
    ObjectName on = ObjectName.getInstance(pattern);
    J4pExecResponse er = jolokia.execute(new J4pExecRequest(on, "browse(String,int,boolean)", route, limit, sortByLongestDuration));
    if (er != null) {
      JSONObject data = er.getValue();
      if (data != null) {
        for (Object obj : data.values()) {
          JSONObject inflight = (JSONObject) obj;
          Map<String, Object> row = new LinkedHashMap<>();
          row.put("exchangeId", asString(inflight.get("exchangeId")));
          row.put("fromRouteId", asString(inflight.get("fromRouteId")));
          row.put("routeId", asString(inflight.get("routeId")));
          row.put("nodeId", asString(inflight.get("nodeId")));
          row.put("elapsed", asString(inflight.get("elapsed")));
          row.put("duration", asString(inflight.get("duration")));
          answer.add(row);
        }
      }
    }
  }
  return answer;
}

代码示例来源:origin: org.apache.camel/camel-commands-jolokia

JSONObject data = response.getValue();
if (data != null) {
  for (Object obj : data.values()) {
    JSONObject data2 = (JSONObject) obj;
    JSONObject service = (JSONObject) data2.values().iterator().next();

代码示例来源:origin: org.apache.camel/camel-commands-jolokia

if (response != null) {
  JSONObject data = response.getValue();
  for (Object obj : data.values()) {
    JSONObject data2 = (JSONObject) obj;
    JSONObject service = (JSONObject) data2.values().iterator().next();

代码示例来源:origin: org.apache.camel/camel-commands-jolokia

JSONObject data = response.getValue();
if (data != null) {
  for (Object obj : data.values()) {
    JSONObject data2 = (JSONObject) obj;
    JSONObject service = (JSONObject) data2.values().iterator().next();

代码示例来源:origin: org.apache.camel/camel-commands-jolokia

if (response != null) {
  JSONObject data = response.getValue();
  for (Object obj : data.values()) {
    JSONObject component = (JSONObject) obj;

代码示例来源:origin: org.jolokia/jolokia-osgi

private void putRowsToTabularData(TabularDataSupport pTabularData, JSONObject pValue, int pLevel) {
    TabularType type = pTabularData.getTabularType();
    for (Object value : pValue.values()) {
      if (!(value instanceof JSONObject)) {
        throw new IllegalArgumentException(
            "Cannot convert " + pValue + " to type " +
            type + " because the object values provided (" + value.getClass() + ") is not of the expected type JSONObject at level " + pLevel);
      }
      JSONObject jsonValue = (JSONObject) value;
      if (pLevel > 1) {
        putRowsToTabularData(pTabularData, jsonValue, pLevel - 1);
      } else {
        pTabularData.put((CompositeData) getDispatcher().convertToObject(type.getRowType(), jsonValue));
      }
    }
  }
}

代码示例来源:origin: org.jolokia/jolokia-core

private void putRowsToTabularData(TabularDataSupport pTabularData, JSONObject pValue, int pLevel) {
    TabularType type = pTabularData.getTabularType();
    for (Object value : pValue.values()) {
      if (!(value instanceof JSONObject)) {
        throw new IllegalArgumentException(
            "Cannot convert " + pValue + " to type " +
            type + " because the object values provided (" + value.getClass() + ") is not of the expected type JSONObject at level " + pLevel);
      }
      JSONObject jsonValue = (JSONObject) value;
      if (pLevel > 1) {
        putRowsToTabularData(pTabularData, jsonValue, pLevel - 1);
      } else {
        pTabularData.put((CompositeData) getDispatcher().convertToObject(type.getRowType(), jsonValue));
      }
    }
  }
}

代码示例来源:origin: org.jolokia/jolokia-service-serializer

private void putRowsToTabularData(TabularDataSupport pTabularData, JSONObject pValue, int pLevel) {
    TabularType type = pTabularData.getTabularType();
    for (Object value : pValue.values()) {
      if (!(value instanceof JSONObject)) {
        throw new IllegalArgumentException(
            "Cannot convert " + pValue + " to type " +
            type + " because the object values provided (" + value.getClass() + ") is not of the expected type JSONObject at level " + pLevel);
      }
      JSONObject jsonValue = (JSONObject) value;
      if (pLevel > 1) {
        putRowsToTabularData(pTabularData, jsonValue, pLevel - 1);
      } else {
        pTabularData.put((CompositeData) getDispatcher().deserialize(type.getRowType(), jsonValue));
      }
    }
  }
}

相关文章