Example usage for com.google.gson FieldNamingPolicy IDENTITY

List of usage examples for com.google.gson FieldNamingPolicy IDENTITY

Introduction

In this page you can find the example usage for com.google.gson FieldNamingPolicy IDENTITY.

Prototype

FieldNamingPolicy IDENTITY

To view the source code for com.google.gson FieldNamingPolicy IDENTITY.

Click Source Link

Document

Using this naming policy with Gson will ensure that the field name is unchanged.

Usage

From source file:com.sangupta.jerry.util.GsonUtils.java

License:Apache License

/**
 * Returns the {@link Gson} instance based on the
 * {@link FieldNamingPolicy#IDENTITY}./*from w  w  w  .j  a  v  a 2 s .c om*/
 * 
 * @return the {@link Gson} object
 */
public static Gson getGson() {
    return getGson(FieldNamingPolicy.IDENTITY);
}

From source file:com.sangupta.satya.client.BaseAuthClient.java

License:Apache License

/**
 * The field naming policy to be used when parsing responses from JSON.
 * 
 * @return
 */
protected FieldNamingPolicy getFieldNamingPolicy() {
    return FieldNamingPolicy.IDENTITY;
}

From source file:com.sangupta.socialcount.SocialCountClient.java

License:Apache License

/**
 * Find the Google Plus shares for a given url.
 * //from  w w w . j  av a  2  s. c om
 * @param counts
 *            the {@link SocialCounts} instance to be updated and containing
 *            the url
 */
public static void getGooglePlusOneCount(SocialCounts counts) {
    String api = "https://clients6.google.com/rpc";
    GoogleRequest googleRequest = new GoogleRequest(counts.url);
    WebRequest request = WebInvoker.getWebRequest(api, WebRequestMethod.POST);
    request.addHeader("Content-type", "application/json");
    request.bodyString(googleRequest.toString(), ContentType.APPLICATION_JSON);

    WebResponse response = WebInvoker.executeSilently(request);
    if (response == null || !response.isSuccess()) {
        return;
    }

    GoogleResponse google = GsonUtils.getGson(FieldNamingPolicy.IDENTITY).fromJson(response.getContent(),
            GoogleResponse.class);
    if (google == null || google.result == null || google.result.metadata == null
            || google.result.metadata.globalCounts == null) {
        return;
    }

    counts.googlePlusOne = (long) google.result.metadata.globalCounts.count;
}

From source file:com.sangupta.socialcount.web.GoogleRequest.java

License:Apache License

@Override
public String toString() {
    return GsonUtils.getGson(FieldNamingPolicy.IDENTITY).toJson(this);
}

From source file:com.shipdream.lib.android.mvc.controller.RetrofitServiceFactory.java

License:Apache License

public RetrofitServiceFactory(String endpoint, Client client) {
    this.endpoint = endpoint;
    this.client = client;

    if (this.endpoint != null) {
        gson = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.IDENTITY)
                .registerTypeAdapter(Date.class, new DateTypeAdapter()).create();
        jsonConverter = new FlexibleConverter(gson, "UTF-8", onSuccessListeners);
        recreateRestAdapter();//w w w  . ja  va 2 s  .c o  m
    }
}

From source file:cph.business.sal.QuoteResource.java

/**
 * Creates a new instance of QuoteResource
 */
public QuoteResource() {
    gson = new GsonBuilder().setPrettyPrinting().setFieldNamingPolicy(FieldNamingPolicy.IDENTITY).create();
}

From source file:dk.cphbusiness.rest.ProjectRestService.java

public ProjectRestService() {
    gson = new GsonBuilder().setPrettyPrinting().setFieldNamingPolicy(FieldNamingPolicy.IDENTITY).create();
}

From source file:dk.cphbusiness.rest.ProjectUserRestSerice.java

public ProjectUserRestSerice() {
    gson = new GsonBuilder().setPrettyPrinting().setFieldNamingPolicy(FieldNamingPolicy.IDENTITY).create();
}

From source file:dk.cphbusiness.rest.RestService.java

/**
 * Creates a new instance of RestService
 */
public RestService() {
    gson = new GsonBuilder().setPrettyPrinting().setFieldNamingPolicy(FieldNamingPolicy.IDENTITY).create();
}

From source file:dk.cphbusiness.rest.RestServiceBook.java

/**
 * Creates a new instance of RestService
 */
public RestServiceBook() {
    gson = new GsonBuilder().setPrettyPrinting().setFieldNamingPolicy(FieldNamingPolicy.IDENTITY).create();
}