Package com.google.gson

Examples of com.google.gson.Gson$FutureTypeAdapter


        return request;
    }

    private SubscriptionResponse getSubscriptionResponse(String jsonBody) throws InstagramException {
        Gson gson = new Gson();
        SubscriptionResponse response;

        try {
            response = gson.fromJson(jsonBody, SubscriptionResponse.class);
        } catch (Exception e) {
            throw new InstagramException("Error parsing json to object type ");
        }

        return response;
View Full Code Here


        return response;
    }

    private SubscriptionsListResponse getSubscriptionsListResponse(String jsonBody) throws InstagramException {
        Gson gson = new Gson();
        SubscriptionsListResponse response = null;

        try {
            response = gson.fromJson(jsonBody, SubscriptionsListResponse.class);
        } catch (Exception e) {
            throw new InstagramException("Error parsing json to object type ");
        }

        return response;
View Full Code Here

            throw handleInstagramError(response);
        }

    protected InstagramException handleInstagramError(Response response) throws InstagramException {
        Gson gson = new Gson();
        final InstagramErrorResponse error;
        try {
            if (response.getCode() == 400) {
                error = InstagramErrorResponse.parse(gson, response.getBody());
                error.setHeaders(response.getHeaders());
View Full Code Here

   * @param response a JSON feed
   * @return a object of type <T>
   * @throws InstagramException if any error occurs.
   */
        protected <T> T createObjectFromResponse(Class<T> clazz, final String response) throws InstagramException {
            Gson gson = new Gson();
            T object;

            try {
                object = clazz.newInstance();
      object = gson.fromJson(response, clazz);
    }
    catch (InstantiationException e) {
      throw new InstagramException("Problem in Instantiation of type " + clazz.getName(), e);
    }
    catch (IllegalAccessException e) {
View Full Code Here

        throw handleInstagramError(response);
    }

    private InstagramException handleInstagramError(Response response) throws InstagramException {
        if (response.getCode() == 400) {
            Gson gson = new Gson();
            final InstagramErrorResponse error = InstagramErrorResponse.parse(gson, response.getBody());
            error.setHeaders(response.getHeaders());
            error.throwException();
        }
        throw new InstagramException("Unknown error response code: " + response.getCode() + " " + response.getBody(), response.getHeaders());
View Full Code Here

     * @param response a JSON feed
     * @return a object of type <T>
     * @throws InstagramException if any error occurs.
     */
    private <T> T createObjectFromResponse(Class<T> clazz, final String response) throws InstagramException {
        Gson gson = new Gson();
        T object = null;

        try {
            object = clazz.newInstance();
            object = gson.fromJson(response, clazz);
        }
        catch (InstantiationException e) {
            throw new InstagramException("Problem in Instantiation of type " + clazz.getName(), e);
        }
        catch (IllegalAccessException e) {
View Full Code Here

      JSONEvent e = new JSONEvent();
      e.setHeaders(input);
      e.setBody(String.valueOf(rand.nextGaussian()).getBytes(encoding));
      events.add(e);
    }
    Gson gson = new Gson();
    String json = gson.toJson(events, listType);
    StringEntity input = new StringEntity(json);
    input.setContentType("application/json; charset=" + encoding);
    postRequest.setEntity(input);
    HttpResponse resp = httpClient.execute(postRequest);
    return new ResultWrapper(resp, events);
View Full Code Here

      JSONEvent e = new JSONEvent();
      e.setHeaders(input);
      e.setBody(String.valueOf(rand.nextGaussian()).getBytes("UTF-8"));
      events.add(e);
    }
    Gson gson = new Gson();
    String json = gson.toJson(events, listType);
    HttpsURLConnection httpsURLConnection = null;
    try {
      TrustManager[] trustAllCerts = {new X509TrustManager() {
        @Override
        public void checkClientTrusted(
View Full Code Here

        JSONEvent e = new JSONEvent();
        e.setHeaders(input);
        e.setBody(String.valueOf(rand.nextGaussian()).getBytes("UTF-8"));
        events.add(e);
    }
    Gson gson = new Gson();
    String json = gson.toJson(events, listType);
    HttpURLConnection httpURLConnection = null;
    try {
        URL url = new URL("http://0.0.0.0:" + sslPort);
        httpURLConnection = (HttpURLConnection) url.openConnection();
        httpURLConnection.setDoInput(true);
View Full Code Here

    if (ttlMs > 0) {
      indexParameters.put(TTL_PARAM, Long.toString(ttlMs));
    }
    parameters.put(INDEX_OPERATION_NAME, indexParameters);

    Gson gson = new Gson();
    synchronized(bulkBuilder) {
      bulkBuilder.append(gson.toJson(parameters));
      bulkBuilder.append("\n");
      bulkBuilder.append(content.toBytesArray().toUtf8());
      bulkBuilder.append("\n");
    }
  }
View Full Code Here

TOP

Related Classes of com.google.gson.Gson$FutureTypeAdapter

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.