Package org.json.simple

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


    @Override
    public FabricRequirements getRequirements() {
        JSONObject obj = Helpers.exec(getJolokiaClient(), "requirements()");
        FabricRequirements requirements = null;
        try {
            requirements = Helpers.getObjectMapper().readValue(obj.toJSONString(), FabricRequirements.class);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return requirements;
    }
View Full Code Here


    @Override
    public AutoScaleStatus getAutoScaleStatus() {
        JSONObject obj = Helpers.exec(getJolokiaClient(), "autoScaleStatus()");
        AutoScaleStatus answer = null;
        try {
            answer = Helpers.getObjectMapper().readValue(obj.toJSONString(), AutoScaleStatus.class);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return answer;
    }
View Full Code Here

    @Override
    public FabricStatus getFabricStatus() {
        JSONObject obj = Helpers.exec(getJolokiaClient(), "fabricStatus()");
        FabricStatus status = null;
        try {
            Map<String, ProfileStatus> profStats = Helpers.getObjectMapper().readValue(obj.toJSONString(), Map.class);
            status = new FabricStatus();
            status.setProfileStatusMap(profStats);
            status.setService(this);
            status.init();
        } catch (Exception ex) {
View Full Code Here

            Number number = asNumber(value);
            return number != null ? number.doubleValue() : null;
        } else if (value instanceof JSONObject) {
            JSONObject jsonObject = (JSONObject) value;
            if (!JSONObject.class.isAssignableFrom(clazz)) {
                String json = jsonObject.toJSONString();
                return RequirementsJson.getMapper().reader(clazz).readValue(json);
            }
        }
        return value;
    }
View Full Code Here

    }
   
    chartJSON.put("elements",elementList);
   
    //render the JSON
    return chartJSON.toJSONString();
  }
}
View Full Code Here

        }

        FileOutputStream fos = null;
        try {
            fos = new FileOutputStream(getProjectInfoFile());
            fos.write(projectInfo.toJSONString().getBytes());
            fos.flush();
        } catch (FileNotFoundException e) {
            throw new CitrusRuntimeException("Unable to open project info file", e);
        } catch (IOException e) {
            throw new CitrusAdminRuntimeException("Unable to write project info file", e);
View Full Code Here

                      break;
                    default:
                      obj.put("state", "idle");
                      break;
                    }
                    return new Response(HttpServer.HTTP_OK, "text/plain", obj.toJSONString());
                  } else {
                    // Nothing is playing
                    JSONObject obj = new JSONObject();
                    obj.put("time", 0);
                    obj.put("duration", 0);
View Full Code Here

                    // Nothing is playing
                    JSONObject obj = new JSONObject();
                    obj.put("time", 0);
                    obj.put("duration", 0);
                    obj.put("state", "stopped");
                    return new Response(HttpServer.HTTP_OK, "text/plain", obj.toJSONString());
                  }
                }
              } else if (uri.startsWith(prefixes[1])) { // devices
                // https://code.google.com/p/json-simple/wiki/EncodingExamples
                JSONArray list = new JSONArray();
View Full Code Here

        JSONObject obj = new JSONObject();
        for (String key : doc.keySet()) {
            Object value = doc.get(key);
            obj.put(key, value);
        }
        return obj.toJSONString();
    }

    private <T extends Document> T fromString(Collection<T> collection, String data) throws ParseException {
        T doc = collection.newDocument(this);
        Map<String, Object> obj = (Map<String, Object>) new JSONParser().parse(data);
View Full Code Here

        assertNotNull("expecing deletionInfo to be present", serializedDeletionInfo);

        assertEquals(
                "unexpected serialization format for topLevelDeletion",
                "{\"markedForDeleteAt\":0,\"localDeletionTime\":0}",
                serializedDeletionInfo.toJSONString());

        // check the colums are what we put in
        JSONArray cols = (JSONArray) row.get("columns");
        assertNotNull("expecing columns to be present", cols);
        assertEquals("expecting two columns", 2, cols.size());
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.