Package com.google.gson

Examples of com.google.gson.JsonParser


      }

      JsonObject ipObject = new JsonObject();

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

      return ipObject;
   }
View Full Code Here


      }

      JsonObject vlanObject = new JsonObject();

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

      return vlanObject;
   }
View Full Code Here

      if (input.getMedia() != null) {
         driveObject.addProperty("media", input.getMedia().toString());
      }

      if (input.getAffinities() != null) {
         driveObject.add("affinities", new JsonParser().parse(new Gson().toJson(input.getAffinities())));
      }

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

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

      driveObject.addProperty("allow_multimount", input.isAllowMultimount());
      return driveObject;
   }
View Full Code Here

    Step step = MiniProfiler.step("API.deserialize");
    try {

      final String[] pieces = splitTokenString(tokenString);
      final String jwtPayloadSegment = pieces[1];
      final JsonParser parser = new JsonParser();
      final String newStringUtf8 = StringUtils.newStringUtf8(Base64
          .decodeBase64(jwtPayloadSegment.getBytes()));
      final JsonElement payload = parser.parse(newStringUtf8);

      return payload.toString();
    } finally {
      step.close();
    }
View Full Code Here

      when(response.getWriter()).thenReturn(new PrintWriter(stringWriter));
     
      customerServlet.doGet(request, response);
     
      // Expect an array with the last entry must be a meta data record (with a attribute _cursor)
      JsonArray array = (new JsonParser()).parse(stringWriter.toString()).getAsJsonArray();
      assertEquals("Checking received numbers of JSON Elements", 2,array.size());
      JsonObject elem  = array.get(array.size()-1).getAsJsonObject();
      assertEquals("Checking that there is a 'cursor' elemen",elem.get("_cursor").getAsString().equals(""),true);

      // TEST: Check the retrieval of a single entry "GET"
View Full Code Here

                 * We have found an existing static large object, so grab the manifest data that
                 * details the existing segments - delete any later that we don't need any more
                 */
                boolean isSLO = "true".equals(existingMetadata.getMetaData().get(Constants.X_STATIC_LARGE_OBJECT).toLowerCase(Locale.ENGLISH));
                if(isSLO) {
                    final JsonParser parser = new JsonParser();
                    URIBuilder urlBuild = new URIBuilder(region.getStorageUrl(container, name));
                    urlBuild.setParameter("multipart-manifest", "get");
                    URI url = urlBuild.build();
                    HttpGet method = new HttpGet(url);
                    Response response = this.execute(method);
                    if(response.getStatusCode() == HttpStatus.SC_OK) {
                        String manifest = response.getResponseBodyAsString();
                        JsonArray segments = parser.parse(manifest).getAsJsonArray();
                        for(JsonElement o : segments) {
                            /*
                             * Parse each JSON object in the list and create a list of Storage Objects
                             */
                            JsonObject segment = o.getAsJsonObject();
View Full Code Here

          responseCache.put(apiKey, data);
        }
      }

      if (data != null) {
        JsonParser parser = new JsonParser();
        JsonElement element = parser.parse(data);
        JsonArray jsonArray = element.getAsJsonArray();

        for (JsonElement elements : jsonArray) {
          JsonObject vpc = elements.getAsJsonObject();
          if (vpc.get("vpc_name") != null) {
View Full Code Here

        return params;
      }

      logger.debug("json retrieved: {}", content);

      JsonParser parser = new JsonParser();
      JsonObject root = (JsonObject) parser.parse(content);

      for (int i = 0; i < types.length; i++) {
        String name = parameterNames[i];
        JsonElement node = root.get(name);
        if (isWithoutRoot(parameterNames, root)) {
View Full Code Here

          + "return JSON.parse(this[" + underlyingFunctionVar + "](JSON.stringify(parameter), (callback == undefined) ? undefined : function(p) { callback(JSON.parse(p)); }));"
        + "};", script);
    wrappee.eval(script, fail, new AsyncScriptFunction<String>() {
      @Override
      public void call(String request, final AsyncScriptFunction.Callback<String> callback) {
        asyncFunction.call((request == null) ? null : new JsonParser().parse(request), new AsyncScriptFunction.Callback<JsonElement>() {
          @Override
          public void handle(JsonElement response) {
            if (response == null) {
              callback.handle(null);
              return;
            }
            if (response.equals(JsonNull.INSTANCE)) {
              callback.handle(null);
              return;
            }
            callback.handle(response.toString());
          }
        });
      }
    }, new SyncScriptFunction<String>() {
      @Override
      public String call(String request) {
        JsonElement r = syncFunction.call((request == null) ? null : new JsonParser().parse(request));
        if (r == null) {
          return null;
        }
        if (r.equals(JsonNull.INSTANCE)) {
          return null;
View Full Code Here

                  zipFile.getInputStream(zipFile.getEntry("appConfig.json")),
                  "UTF-8");
              String resourcesJsonString = IOUtils.toString(
                  zipFile.getInputStream(zipFile.getEntry("resources.json")),
                  "UTF-8");
              JsonElement appConfigJson = new JsonParser()
                  .parse(appConfigJsonString);
              JsonElement resourcesJson = new JsonParser()
                  .parse(resourcesJsonString);
              SliderAppType appType = new SliderAppType();
              appType.setId(service.getName());
              appType.setTypeName(service.getName());
              appType.setTypeDescription(service.getComment());
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.