Package com.google.gson

Examples of com.google.gson.JsonParser


      get.setDoAuthentication(true);
    }
    int executeMethod = getHttpClient().executeMethod(get);
    switch (executeMethod) {
    case HttpStatus.SC_OK:
      JsonElement jsonElement = new JsonParser().parse(new JsonReader(
          new InputStreamReader(get.getResponseBodyAsStream())));
      return jsonElement;
    default:
      break;
    }
View Full Code Here


  @Consumes({ MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON })
  public Response updateApp(@Context UriInfo uri, String jsonString,
      @PathParam("appId") String appId) throws IOException, YarnException,
      InterruptedException, URISyntaxException {
    if (jsonString != null) {
      JsonElement requestContent = new JsonParser().parse(jsonString);
      if (requestContent != null && appId != null) {
        JsonObject requestJson = requestContent.getAsJsonObject();
        if (requestJson.has("state")) {
          String newState = requestJson.get("state").getAsString();
          if ("FROZEN".equals(newState))
View Full Code Here

  @Consumes({ MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON })
  public Response createApp(@Context UriInfo uri, String jsonString)
      throws IOException, YarnException, InterruptedException,
      URISyntaxException {
    if (jsonString != null) {
      JsonElement requestContent = new JsonParser().parse(jsonString);
      String sliderApp = sliderAppsViewController
          .createSliderApp(requestContent.getAsJsonObject());
      if (sliderApp != null)
        return Response.created(new URI(uri.getAbsolutePath() + sliderApp))
            .build();
View Full Code Here

                if(contentType.getCharset() != null) {
                    charset = contentType.getCharset();
                }
            }
            try {
                final JsonParser parser = new JsonParser();
                final JsonObject json = parser.parse(new InputStreamReader(response.getEntity().getContent(), charset)).getAsJsonObject();
                final JsonObject auth = json.getAsJsonObject("access");
                final JsonObject user = auth.getAsJsonObject("user");
                String defaultRegion = null;
                if(user.get("RAX-AUTH:defaultRegion") != null) {
                    defaultRegion = user.get("RAX-AUTH:defaultRegion").getAsString();
View Full Code Here

                if(contentType.getCharset() != null) {
                    charset = contentType.getCharset();
                }
            }
            try {
                final JsonParser parser = new JsonParser();
                final JsonObject json = parser.parse(new InputStreamReader(response.getEntity().getContent(), charset)).getAsJsonObject();
                final JsonObject auth = json.getAsJsonObject("auth");
                final String token = auth.getAsJsonObject("token").get("id").getAsString();
                final Map<String, String> cdnUrls = new HashMap<String, String>();
                JsonObject serviceCatalog = auth.getAsJsonObject("serviceCatalog");
                for(JsonElement e : serviceCatalog.getAsJsonArray("cloudFilesCDN")) {
View Full Code Here

    }
    return response;
  }
 
  private JsonElement execute(String url, JsonElement request) throws IOException {
    return new JsonParser().parse(execute(url, request.toString()));
  }
View Full Code Here

    // Define Remote Service Url
    String url = url(urlPattern, args);

    // Wrap Into Object
    TypeToken<T> type = TypeToken.get(clazz);
    T o = unmarshall(type, ((JsonObject) new JsonParser().parse(getStringData(url))).get(arrayName));

    // Return Results
    return o;
  }
View Full Code Here

    // Init Results List
    List<T> list = new ArrayList<T>();

    // Wrap response into list of objects
    TypeToken<T> type = TypeToken.get(clazz);
    JsonArray array = (JsonArray) ((JsonObject) new JsonParser().parse(getStringData(url))).get(arrayName);
    if ((array != null) && (array.size() > 0)) {
      for (JsonElement element : array) {
        T o = unmarshall(type, element);
        list.add(o);
      }
View Full Code Here

      throw new AuthenticationServiceException("Unable to obtain Access Token: " + httpClientErrorException.getMessage());
    }

    logger.debug("from TokenEndpoint jsonString = " + jsonString);

    JsonElement jsonRoot = new JsonParser().parse(jsonString);
    if (!jsonRoot.isJsonObject()) {
      throw new AuthenticationServiceException("Token Endpoint did not return a JSON object: " + jsonRoot);
    }

    JsonObject tokenResponse = jsonRoot.getAsJsonObject();
View Full Code Here

    } catch (RestClientException rce) {
      logger.error("validateToken", rce);
    }
    if (validatedToken != null) {
      // parse the json
      JsonElement jsonRoot = new JsonParser().parse(validatedToken);
      if (!jsonRoot.isJsonObject()) {
        return false; // didn't get a proper JSON object
      }

      JsonObject tokenResponse = jsonRoot.getAsJsonObject();
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.