當前位置: 首頁>>代碼示例>>Java>>正文


Java GsonBuilder.setFieldNamingPolicy方法代碼示例

本文整理匯總了Java中com.google.gson.GsonBuilder.setFieldNamingPolicy方法的典型用法代碼示例。如果您正苦於以下問題:Java GsonBuilder.setFieldNamingPolicy方法的具體用法?Java GsonBuilder.setFieldNamingPolicy怎麽用?Java GsonBuilder.setFieldNamingPolicy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.gson.GsonBuilder的用法示例。


在下文中一共展示了GsonBuilder.setFieldNamingPolicy方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: unpack

import com.google.gson.GsonBuilder; //導入方法依賴的package包/類
public void unpack(@NonNull final JSONObject payload) {
    if (DEBUG) {
        MyLog.i(CLS_NAME, "unpacking");
    }

    final GsonBuilder builder = new GsonBuilder();
    builder.disableHtmlEscaping();
    builder.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES);

    final Gson gson = builder.create();
    nluNuance = gson.fromJson(payload.toString(), new TypeToken<NLUNuance>() {
    }.getType());

    new NLUCoerce(getNLUNuance(), getContext(), getSupportedLanguage(), getVRLocale(), getTTSLocale(),
            getConfidenceArray(), getResultsArray()).coerce();
}
 
開發者ID:brandall76,項目名稱:Saiy-PS,代碼行數:17,代碼來源:ResolveNuance.java

示例2: unpack

import com.google.gson.GsonBuilder; //導入方法依賴的package包/類
public void unpack(@NonNull final JSONObject payload) {
    if (DEBUG) {
        MyLog.i(CLS_NAME, "unpacking");
    }

    final GsonBuilder builder = new GsonBuilder();
    builder.disableHtmlEscaping();
    builder.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES);

    final Gson gson = builder.create();
    nluSaiy = gson.fromJson(payload.toString(), new TypeToken<NLUSaiy>() {
    }.getType());

    new NLUCoerce(getNLUSaiy(), getContext(), getSupportedLanguage(), getVRLocale(), getTTSLocale(),
            getConfidenceArray(), getResultsArray()).coerce();
}
 
開發者ID:brandall76,項目名稱:Saiy-PS,代碼行數:17,代碼來源:ResolveSaiy.java

示例3: createGson

import com.google.gson.GsonBuilder; //導入方法依賴的package包/類
/**
     * Create the standard {@link Gson} configuration
     *
     * @param serializeNulls whether nulls should be serialized
     * @return created gson, never null
     */
    public static final Gson createGson(final boolean serializeNulls) {
        final GsonBuilder builder = new GsonBuilder();
//		builder.registerTypeAdapter(Date.class, new DateFormatter());
//		builder.registerTypeAdapter(Event.class, new EventFormatter());
        builder.setFieldNamingPolicy(LOWER_CASE_WITH_UNDERSCORES);
        if (serializeNulls)
            builder.serializeNulls();
        return builder.create();
    }
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:16,代碼來源:GsonUtils.java

示例4: call

import com.google.gson.GsonBuilder; //導入方法依賴的package包/類
public static TmdbService call() {
    GsonBuilder gsonBuilder = new GsonBuilder();
    gsonBuilder.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES);

    Gson gson = gsonBuilder.create();

    OkHttpClient client = new OkHttpClient.Builder().addInterceptor(new Interceptor() {
        @Override
        public Response intercept(Chain chain) throws IOException {
            Request request = chain.request();
            HttpUrl url = request.url().newBuilder()
                    .addQueryParameter("api_key", API_KEY)
                    .build();

            request = request.newBuilder().url(url).build();

            return chain.proceed(request);
        }
    }).build();

    Retrofit retrofit = new Retrofit.Builder()
            .baseUrl(BASE_URL)
            .client(client)
            .addConverterFactory(GsonConverterFactory.create(gson))
            .build();

    return retrofit.create(TmdbService.class);
}
 
開發者ID:ramadani,項目名稱:Pilem,代碼行數:29,代碼來源:ApiBuilder.java

示例5: provideGson

import com.google.gson.GsonBuilder; //導入方法依賴的package包/類
@Provides
@AppScope
Gson provideGson() {
    GsonBuilder gsonBuilder = new GsonBuilder();
    gsonBuilder.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES);
    return gsonBuilder.create();
}
 
開發者ID:Jusenr,項目名稱:androidgithub,代碼行數:8,代碼來源:ApiModule.java

示例6: provideGson

import com.google.gson.GsonBuilder; //導入方法依賴的package包/類
@Provides
@Singleton
Gson provideGson() {
    GsonBuilder gsonBuilder = new GsonBuilder();
    gsonBuilder.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES);
    return gsonBuilder.create();
}
 
開發者ID:ragdroid,項目名稱:mockstar,代碼行數:8,代碼來源:ApiModule.java

示例7: provideGson

import com.google.gson.GsonBuilder; //導入方法依賴的package包/類
@Provides
@Singleton
static Gson provideGson() {
    GsonBuilder gsonBuilder = new GsonBuilder();
    gsonBuilder.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES);
    return gsonBuilder.create();
}
 
開發者ID:ragdroid,項目名稱:Dahaka,代碼行數:8,代碼來源:ApiModule.java


注:本文中的com.google.gson.GsonBuilder.setFieldNamingPolicy方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。