本文整理汇总了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();
}
示例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();
}
示例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();
}
示例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);
}
示例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();
}
示例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();
}
示例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();
}