Java Code Examples for com.google.gson.GsonBuilder#setFieldNamingStrategy()

The following examples show how to use com.google.gson.GsonBuilder#setFieldNamingStrategy() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JsonUtils.java    From YCAudioPlayer with Apache License 2.0 5 votes vote down vote up
/**
 * 第一种方式
 * @return              Gson对象
 */
public static Gson getJson() {
    if (gson == null) {
        GsonBuilder builder = new GsonBuilder();
        builder.setLenient();
        builder.setFieldNamingStrategy(new AnnotateNaming());
        builder.serializeNulls();
        gson = builder.create();
    }
    return gson;
}
 
Example 2
Source File: HttpUtils.java    From qvod with MIT License 5 votes vote down vote up
private Gson getGson() {
    if (gson == null) {
        GsonBuilder gsonBuilder = new GsonBuilder();
        gsonBuilder.setFieldNamingStrategy(new AnnotateNaming());
        gsonBuilder.serializeNulls();
        gsonBuilder.excludeFieldsWithModifiers(Modifier.TRANSIENT);
        gson = gsonBuilder.create();
    }
    return gson;
}
 
Example 3
Source File: HttpUtils.java    From CloudReader with Apache License 2.0 5 votes vote down vote up
private Gson getGson() {
    if (gson == null) {
        GsonBuilder builder = new GsonBuilder();
        builder.setLenient();
        builder.setFieldNamingStrategy(new AnnotateNaming());
        builder.serializeNulls();
        gson = builder.create();
    }
    return gson;
}