Package org.json.simple

Examples of org.json.simple.JSONObject.keySet()


    double user = 0.0;
    double sys = 0.0;
    double idle = 0.0;
    for(int i = 0; i< cpuList.size(); i++) {
      JSONObject cpu = (JSONObject) cpuList.get(i);
      Iterator<String> keys = cpu.keySet().iterator();
      combined = combined + Double.parseDouble(cpu.get("combined").toString());
      user = user + Double.parseDouble(cpu.get("user").toString());
      sys = sys + Double.parseDouble(cpu.get("sys").toString());
      idle = idle + Double.parseDouble(cpu.get("idle").toString());
      while(keys.hasNext()) {
View Full Code Here


    buildGenericRecord(record, null, cal.getTimeInMillis(), "system");
    output.collect(key, record);   

    record = new ChukwaRecord();
    JSONObject memory = (JSONObject) json.get("memory");
    Iterator<String> memKeys = memory.keySet().iterator();
    while(memKeys.hasNext()) {
      String key = memKeys.next();
      record.add(key, memory.get(key).toString());
    }
    buildGenericRecord(record, null, cal.getTimeInMillis(), "memory");
View Full Code Here

    buildGenericRecord(record, null, cal.getTimeInMillis(), "memory");
    output.collect(key, record);   

    record = new ChukwaRecord();
    JSONObject swap = (JSONObject) json.get("swap");
    Iterator<String> swapKeys = swap.keySet().iterator();
    while(swapKeys.hasNext()) {
      String key = swapKeys.next();
      record.add(key, swap.get(key).toString());
    }
    buildGenericRecord(record, null, cal.getTimeInMillis(), "swap");
View Full Code Here

    double txPackets = 0;
    record = new ChukwaRecord();
    JSONArray netList = (JSONArray) json.get("network");
    for(int i = 0;i < netList.size(); i++) {
      JSONObject netIf = (JSONObject) netList.get(i);
      Iterator<String> keys = netIf.keySet().iterator();
      while(keys.hasNext()) {
        String key = keys.next();
        record.add(key + "." + i, netIf.get(key).toString());
        if(i!=0) {
          if(key.equals("RxBytes")) {
View Full Code Here

    double writes = 0;
    record = new ChukwaRecord();
    JSONArray diskList = (JSONArray) json.get("disk");
    for(int i = 0;i < diskList.size(); i++) {
      JSONObject disk = (JSONObject) diskList.get(i);
      Iterator<String> keys = disk.keySet().iterator();
      while(keys.hasNext()) {
        String key = keys.next();
        record.add(key + "." + i, disk.get(key).toString());
        if(key.equals("ReadBytes")) {
          readBytes = readBytes + (Long) disk.get("ReadBytes");
View Full Code Here

           
            SSTableWriter writer = new SSTableWriter(ssTablePath, json.size());
            SortedMap<DecoratedKey,String> decoratedKeys = new TreeMap<DecoratedKey,String>();
           
            // sort by dk representation, but hold onto the hex version
            for (String key : (Set<String>)json.keySet())
                decoratedKeys.put(partitioner.decorateKey(ByteBuffer.wrap(hexToBytes(key))), key);

            for (Map.Entry<DecoratedKey, String> rowKey : decoratedKeys.entrySet())
            {
                if (cfType == ColumnFamilyType.Super)
View Full Code Here

             JSONParser parser = new JSONParser();
               Object obj = parser.parse(textEntity);
     
               JSONObject jsonObject = (JSONObject) obj;
     
               Iterator iter = jsonObject.keySet().iterator();
     
               while (iter.hasNext()) {
                    Object key = iter.next();
                    JSONObject msg = (JSONObject) jsonObject.get(key);
                    if (msg.get("  STATUS") == null) {
View Full Code Here

                                           MapWritable value) {
      log.info("Got string '{}'", line);
      try {
        JSONObject jsonObj =
            (JSONObject) parser.parse(line.toString());
        for (Object key : jsonObj.keySet()) {
          Text mapKey = new Text(key.toString());
          Text mapValue = new Text();
          if (jsonObj.get(key) != null) {
            mapValue.set(jsonObj.get(key).toString());
          }
View Full Code Here

    }

    private static void addErrorPages(Context context, JSONObject obj) {
        JSONObject arr = (JSONObject) obj.get(JaggeryCoreConstants.JaggeryConfigParams.ERROR_PAGES);
        if (arr != null) {
            for (Object keys : arr.keySet()) {
                ErrorPage errPage = new ErrorPage();
                errPage.setErrorCode((String) keys);
                errPage.setLocation((String) arr.get(keys));
                context.addErrorPage(errPage);
            }
View Full Code Here

        Params p = new Params();
        p.add("id", getID());
        Map response = en.getCmd().sendCommand("catalog/keyvalues", p);
        JSONObject kv = (JSONObject) response.get("keyvalues");
        Map<String, String> results = new HashMap<String, String>();
        for (Object key : kv.keySet()) {
            Object val = kv.get(key);
            results.put((String) key, (String) val);
        }
        return results;
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.