Package com.google.gson

Examples of com.google.gson.JsonParser


    }
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    ByteStreams.copy(response.getEntity().getContent(), bos);
    String responseBody = bos.toString("UTF-8");
    bos.close();
    JsonParser parser = new JsonParser();
    JsonObject responseJson = (JsonObject) parser.parse(responseBody);
    JsonArray addresses = responseJson.get("auth_uri").getAsJsonArray();
    ArrayList<String> list = new ArrayList<String>();
    for (JsonElement e : addresses) {
      list.add(e.getAsString());
    }
View Full Code Here


      try {
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        ByteStreams.copy(response.getEntity().getContent(), bos);
        String responseBody = bos.toString("UTF-8");
        bos.close();
        JsonParser parser = new JsonParser();
        JsonObject responseJson = (JsonObject) parser.parse(responseBody);
        String token = responseJson.get(ExternalAuthenticationServer.ResponseFields.ACCESS_TOKEN).getAsString();

        PrintWriter writer = new PrintWriter(filePath, "UTF-8");
        writer.write(token);
        writer.close();
View Full Code Here

      throw new EtcdClientException("Error listing keys", etcdResult);
    }

    try {
      List<EtcdResult> ret = new ArrayList<EtcdResult>();
      JsonParser parser = new JsonParser();
      JsonArray array = parser.parse(response.json).getAsJsonArray();
      for (int i = 0; i < array.size(); i++) {
        EtcdResult next = gson.fromJson(array.get(i), EtcdResult.class);
        ret.add(next);
      }
      return ret;
View Full Code Here

public class GsonArguments implements Arguments {

    private final JsonArray jsonArray;

    public GsonArguments(String json) {
        this(new JsonParser().parse(checkNotNull(json, "json")).getAsJsonArray());
    }
View Full Code Here

            ack.acknowledge(data != null ? new GsonArguments(data) : null);
        }
    }

    private void receiveEvent(Packet packet) {
        JsonObject eventData = new JsonParser().parse(packet.getData()).getAsJsonObject();

        String name = eventData.get("name").getAsString();
        Arguments args = new GsonArguments(eventData.getAsJsonArray("args"));

        // If there is an id, the packet requires acknowledgement
View Full Code Here

      metaMap.put("install_notes", "test_install_notes");

      result.addProperty("name", "test");
      result.addProperty("size", "1024000000");
      result.addProperty("media", "disk");
      result.add("affinities", new JsonParser().parse(new Gson().toJson(affinities)));
      result.add("meta", new JsonParser().parse(new Gson().toJson(metaMap)));
      result.add("tags", new JsonParser().parse(new Gson().toJson(tags)));
      result.addProperty("allow_multimount", false);

      input = new DriveInfo.Builder()
            .affinities(ImmutableList.of("ssd", "sample"))
            .allowMultimount(false)
View Full Code Here

      if (input.getName() != null) {
         jsonTag.addProperty("name", input.getName());
      }

      if (input.getMeta() != null) {
         jsonTag.add("meta", new JsonParser().parse(new Gson().toJson(input.getMeta())));
      }

      if (input.getResources() != null && input.getResources().size() != 0) {
         JsonArray uuidsArray = new JsonArray();
View Full Code Here

      if (input.getMemory() != null) {
         serverObject.addProperty("mem", input.getMemory().toString());
      }

      if (input.getMeta() != null) {
         serverObject.add("meta", new JsonParser().parse(new Gson().toJson(input.getMeta())));
      }

      if (input.getRequirements() != null) {
         serverObject.add("requirements", new JsonParser().parse(new Gson().toJson(input.getRequirements())));
      }

      if (input.getTags() != null) {
         serverObject.add("tags", new JsonParser().parse(new Gson().toJson(input.getTags())));
      }

      if (input.getVncPassword() != null) {
         serverObject.addProperty("vnc_password", input.getVncPassword());
      }
View Full Code Here

      if (input.getLastName() != null) {
         profileJson.addProperty("last_name", input.getLastName());
      }

      if (input.getMeta() != null) {
         profileJson.add("meta", new JsonParser().parse(new Gson().toJson(input.getMeta())));
      }

      if (input.getMyNotes() != null) {
         profileJson.addProperty("my_notes", input.getMyNotes());
      }
View Full Code Here

      if (input.getName() != null) {
         firewallObject.addProperty("name", input.getName());
      }

      if (input.getMeta() != null) {
         firewallObject.add("meta", new JsonParser().parse(new Gson().toJson(input.getMeta())));
      }

      if (input.getRules() != null) {
         JsonArray rulesArray = new JsonArray();
View Full Code Here

TOP

Related Classes of com.google.gson.JsonParser

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.