Package com.eclipsesource.json

Examples of com.eclipsesource.json.JsonArray


    }

    @Override
    public void writeResponse(ManagementCenterService mcs, JsonObject root) {
        final JsonObject result = new JsonObject();
        JsonArray logs = new JsonArray();
        result.add("logs", logs);
        root.add("result", result);
    }
View Full Code Here


    @Override
    public JsonObject toJson() {
        final JsonObject root = new JsonObject();
        root.add("script", script);
        root.add("engine", engine);
        JsonArray jsonTargets = new JsonArray();
        for (String target : targets) {
            jsonTargets.add(target);
        }
        root.add("targets", jsonTargets);
        root.add("targetAllMembers", targetAllMembers);
        return root;
    }
View Full Code Here

    @Override
    public void fromJson(JsonObject json) {
        script = getString(json, "script", "");
        engine = getString(json, "engine", "");
        targets = new HashSet<String>();
        for (JsonValue target : getArray(json, "targets", new JsonArray())) {
            targets.add(target.asString());
        }
        targetAllMembers = getBoolean(json, "targetAllMembers", false);
        bindings = new HashMap<String, Object>();
    }
View Full Code Here

    }

    @Override
    public void writeResponse(ManagementCenterService mcs, JsonObject root) throws Exception {
        final JsonObject result = new JsonObject();
        JsonArray logs = new JsonArray();
        result.add("logs", logs);
        root.add("result", result);
    }
View Full Code Here

        JsonObject runtimePropsObject = new JsonObject();
        for (Map.Entry<String, Long> entry : runtimeProps.entrySet()) {
            runtimePropsObject.add(entry.getKey(), entry.getValue());
        }
        root.add("runtimeProps", runtimePropsObject);
        JsonArray partitionsArray = new JsonArray();
        for (Integer lsPartition : partitions) {
            partitionsArray.add(lsPartition);
        }
        root.add("partitions", partitionsArray);
        JsonArray clientsArray = new JsonArray();
        for (SerializableClientEndPoint client : clients) {
            clientsArray.add(client.toJson());
        }
        root.add("clients", clientsArray);
        root.add("beans", beans.toJson());
        root.add("memoryStats", memoryStats.toJson());
        return root;
View Full Code Here

            cacheStats.put(next.getName(), stats);
        }
        for (JsonObject.Member next : getObject(json, "runtimeProps")) {
            runtimeProps.put(next.getName(), next.getValue().asLong());
        }
        final JsonArray jsonPartitions = getArray(json, "partitions");
        for (JsonValue jsonPartition : jsonPartitions) {
            partitions.add(jsonPartition.asInt());
        }
        final JsonArray jsonClients = getArray(json, "clients");
        for (JsonValue jsonClient : jsonClients) {
            final SerializableClientEndPoint client = new SerializableClientEndPoint();
            client.fromJson(jsonClient.asObject());
            clients.add(client);
        }
View Full Code Here

    public JsonObject toJson() {
        JsonObject root = new JsonObject();
        root.add("master", master);
        root.add("time", time);
        root.add("clusterName", clusterName);
        JsonArray instanceNames = new JsonArray();
        for (String instanceName : this.instanceNames) {
            instanceNames.add(instanceName);
        }
        root.add("instanceNames", instanceNames);
        if (memberList != null) {
            JsonArray members = new JsonArray();
            for (String member : memberList) {
                members.add(member);
            }
            root.add("memberList", members);
        }
        root.add("memberState", memberState.toJson());
        return root;
View Full Code Here

    public void fromJson(JsonObject json) {
        time = getLong(json, "time");
        master = getBoolean(json, "master");
        clusterName = getString(json, "clusterName");
        instanceNames = new HashSet<String>();
        final JsonArray jsonInstanceNames = getArray(json, "instanceNames");
        for (JsonValue instanceName : jsonInstanceNames.values()) {
            instanceNames.add(instanceName.asString());
        }
        memberList = new ArrayList<String>();
        final JsonArray jsonMemberList = getArray(json, "memberList");
        for (JsonValue member : jsonMemberList.values()) {
            memberList.add(member.asString());
        }
        final JsonObject jsonMemberState = getObject(json, "memberState");
        memberState = new MemberStateImpl();
        memberState.fromJson(jsonMemberState);
View Full Code Here

  @Test
  public void prettyPrint_withNestedArray() {
    JsonObject object = new JsonObject()
      .add( "foo", true )
      .add( "bar", new JsonArray().add( 23 ).add( 42 ) );

    assertEquals( "{\n  \"foo\": true,\n  \"bar\": [23, 42]\n}", JsonUtil.prettyPrint( object ) );
  }
View Full Code Here

    assertNotNull( jsonObject );
  }

  @Test
  public void mockArray() {
    JsonArray jsonArray = Mockito.mock( JsonArray.class );

    assertNotNull( jsonArray );
  }
View Full Code Here

TOP

Related Classes of com.eclipsesource.json.JsonArray

Copyright © 2018 www.massapicom. 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.