List of usage examples for com.google.gson FieldNamingPolicy LOWER_CASE_WITH_UNDERSCORES
FieldNamingPolicy LOWER_CASE_WITH_UNDERSCORES
To view the source code for com.google.gson FieldNamingPolicy LOWER_CASE_WITH_UNDERSCORES.
Click Source Link
From source file:org.lastaflute.doc.generator.ActionDocumentGenerator.java
License:Apache License
protected String adjustFieldName(Class<?> clazz, Field field) { // TODO p1us2er0 judge accurately in adjustFieldName() (2017/04/20) if (clazz.getSimpleName().endsWith("Form")) { return field.getName(); }// ww w . j a v a2s . c o m return getApplicationJsonMappingOption().flatMap(jsonMappingOption -> { return jsonMappingOption.getFieldNaming().map(naming -> { if (naming == JsonFieldNaming.IDENTITY) { return FieldNamingPolicy.IDENTITY.translateName(field); } else if (naming == JsonFieldNaming.CAMEL_TO_LOWER_SNAKE) { return FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES.translateName(field); } else { return field.getName(); } }); }).orElse(field.getName()); }
From source file:org.matrix.androidsdk.MXDataHandler.java
License:Apache License
/** * Refresh the push rules from the account data events list * @param events the account data events. *//*from w w w . j ava2 s. c o m*/ private void managePushRulesUpdate(List<Map<String, Object>> events) { for (Map<String, Object> event : events) { String type = (String) event.get("type"); if (TextUtils.equals(type, "m.push_rules")) { if (event.containsKey("content")) { Gson gson = new GsonBuilder() .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) .excludeFieldsWithModifiers(Modifier.PRIVATE, Modifier.STATIC) .registerTypeAdapter(Condition.class, new ConditionDeserializer()).create(); // convert the data to BingRulesResponse // because BingRulesManager supports only BingRulesResponse JsonElement element = gson.toJsonTree(event.get("content")); getBingRulesManager().buildRules(gson.fromJson(element, BingRulesResponse.class)); // warn the client that the push rules have been updated onBingRulesUpdate(); } return; } } }
From source file:org.ohmage.dagger.OhmageModule.java
License:Apache License
@Provides @Singleton/* www . j a va 2s . c o m*/ Gson provideGson() { GsonBuilder gson = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) .registerTypeAdapterFactory(new LowercaseEnumTypeAdapterFactory()) .registerTypeAdapter(Prompt.class, new BasePrompt.PromptDeserializer()) .registerTypeAdapter(Double.class, new JsonSerializer<Double>() { @Override public JsonElement serialize(Double src, Type typeOfSrc, JsonSerializationContext context) { if ((src == Math.floor(src)) && !Double.isInfinite(src)) { return context.serialize(src.intValue()); } return context.serialize(src); } }); TriggerInit.injectDeserializers(gson); return gson.create(); }
From source file:org.openhab.binding.airvisualnode.internal.handler.AirVisualNodeHandler.java
License:Open Source License
public AirVisualNodeHandler(Thing thing) { super(thing); gson = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create(); }
From source file:org.openhab.binding.freebox.internal.api.FreeboxApiManager.java
License:Open Source License
public FreeboxApiManager(String appId, String appName, String appVersion, String deviceName) { this.appId = appId; this.appName = appName; this.appVersion = appVersion; this.deviceName = deviceName; this.gson = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create(); }
From source file:org.openhab.binding.tplinksmarthome.internal.model.GsonUtil.java
License:Open Source License
/** * Creates a new {@link Gson} object./*from w w w.j av a2s . co m*/ * * @return new {@link Gson} object. */ public static Gson createGson() { return new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create(); }
From source file:org.openhab.binding.tplinksmarthome.internal.model.GsonUtil.java
License:Open Source License
/** * Creates a new {@link Gson} object that uses the {@link Expose} annotation.. * * @return new {@link Gson} object.//from w w w .java 2 s . com */ public static Gson createGsonWithExpose() { return new GsonBuilder().excludeFieldsWithoutExposeAnnotation() .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create(); }
From source file:org.openhab.binding.unifi.internal.api.model.UniFiController.java
License:Open Source License
public UniFiController(HttpClient httpClient, String host, int port, String username, String password) { this.httpClient = httpClient; this.host = host; this.port = port; this.username = username; this.password = password; UniFiSiteInstanceCreator siteInstanceCreator = new UniFiSiteInstanceCreator(this); UniFiDeviceInstanceCreator deviceInstanceCreator = new UniFiDeviceInstanceCreator(this); UniFiClientInstanceCreator clientInstanceCreator = new UniFiClientInstanceCreator(this); this.gson = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) .registerTypeAdapter(UniFiSite.class, siteInstanceCreator) .registerTypeAdapter(UniFiDevice.class, deviceInstanceCreator) .registerTypeAdapter(UniFiClient.class, new UniFiClientDeserializer()) .registerTypeAdapter(UniFiUnknownClient.class, clientInstanceCreator) .registerTypeAdapter(UniFiWiredClient.class, clientInstanceCreator) .registerTypeAdapter(UniFiWirelessClient.class, clientInstanceCreator).create(); }
From source file:org.openhab.binding.unifi.internal.api.UniFiController.java
License:Open Source License
public UniFiController(HttpClient httpClient, String host, int port, String username, String password) { this.httpClient = httpClient; this.host = host; this.port = port; this.username = username; this.password = password; this.gson = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) .registerTypeAdapter(UniFiClient.class, new UniFiClientDeserializer()).create(); }
From source file:org.quizpoll.net.HttpHelper.java
License:Open Source License
/** * Creates new GSON parser instance, is used in subclasses */// w ww . j av a 2 s.co m protected Gson getGson() { return new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create(); }