congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
GsonBuilder.setFieldNamingPolicy
Code IndexAdd Tabnine to your IDE (free)

How to use
setFieldNamingPolicy
method
in
com.google.gson.GsonBuilder

Best Java code snippets using com.google.gson.GsonBuilder.setFieldNamingPolicy (Showing top 20 results out of 657)

origin: stackoverflow.com

 GsonBuilder builder = new GsonBuilder();
builder.registerTypeAdapter(CityList.class, new CityListDeserializer());
Gson gson = builder.setFieldNamingPolicy(LOWER_CASE_WITH_UNDERSCORES).create();
CityList list = gson.fromJson(json, CityList.class);
origin: jgilfelt/chuck

  public static Gson getInstance() {
    if (gson == null) {
      gson = new GsonBuilder()
          .setPrettyPrinting()
          .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
          .registerTypeAdapter(Date.class, new DateTypeAdapter())
          .create();
    }
    return gson;
  }
}
origin: stackoverflow.com

gsonBuilder.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES);
gsonBuilder.registerTypeAdapter(Timestamp.class, new TimestampDeserializer());
Gson gson = gsonBuilder.create();
origin: kairosdb/kairosdb

@Inject
public QueryParser(FeatureProcessor processingChain, QueryPluginFactory pluginFactory)
{
  m_processingChain = processingChain;
  m_pluginFactory = pluginFactory;
  m_descriptorMap = new HashMap<>();
  GsonBuilder gsonBuilder = new GsonBuilder();
  gsonBuilder.registerTypeAdapterFactory(new LowercaseEnumTypeAdapterFactory());
  gsonBuilder.registerTypeAdapter(TimeUnit.class, new TimeUnitDeserializer());
  gsonBuilder.registerTypeAdapter(TrimAggregator.Trim.class, new TrimDeserializer());
  gsonBuilder.registerTypeAdapter(FilterAggregator.FilterOperation.class, new FilterOperationDeserializer());
  gsonBuilder.registerTypeAdapter(DateTimeZone.class, new DateTimeZoneDeserializer());
  gsonBuilder.registerTypeAdapter(Metric.class, new MetricDeserializer());
  gsonBuilder.registerTypeAdapter(SetMultimap.class, new SetMultimapDeserializer());
  gsonBuilder.registerTypeAdapter(RelativeTime.class, new RelativeTimeSerializer());
  gsonBuilder.registerTypeAdapter(SetMultimap.class, new SetMultimapSerializer());
  gsonBuilder.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES);
  m_gson = gsonBuilder.create();
}
origin: googlemaps/google-maps-services-java

.registerTypeAdapter(LocalTime.class, new LocalTimeAdapter())
.registerTypeAdapter(GeolocationApi.Response.class, new GeolocationResponseAdapter())
.setFieldNamingPolicy(fieldNamingPolicy)
.create();
origin: googlemaps/google-maps-services-java

.registerTypeAdapter(GeolocationApi.Response.class, new GeolocationResponseAdapter())
.registerTypeAdapter(EncodedPolyline.class, new EncodedPolylineInstanceCreator(""))
.setFieldNamingPolicy(fieldNamingPolicy)
.create();
origin: apache/cloudstack

public NeutronNetworksNorthboundAction(final URL url, final String username, final String password) {
  super(url, username, password);
  gsonNeutronNetwork = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create();
}
origin: apache/cloudstack

public NeutronNodesNorthboundAction(final URL url, final String username, final String password) {
  super(url, username, password);
  gsonNeutronNode = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create();
}
origin: apache/cloudstack

public NeutronPortsNorthboundAction(final URL url, final String username, final String password) {
  super(url, username, password);
  gsonNeutronPort = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create();
}
origin: apache/cloudstack

private static Gson setGsonDeserializer(final Map<Class<?>, JsonDeserializer<?>> classToDeserializerMap) {
  final GsonBuilder gsonBuilder = new GsonBuilder();
  for (final Map.Entry<Class<?>, JsonDeserializer<?>> entry : classToDeserializerMap.entrySet()) {
    gsonBuilder.registerTypeAdapter(entry.getKey(), entry.getValue());
  }
  return gsonBuilder.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create();
}
origin: stackoverflow.com

gsonBuilder.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES);
gsonBuilder.registerTypeAdapter(Child[].class, new ChildrenDeserializer());
Gson gson = gsonBuilder.create();
origin: rharter/auto-value-gson

private Gson getGsonWithNamingPolicy(FieldNamingPolicy fieldNamingPolicy){
  return new GsonBuilder()
      .setFieldNamingPolicy(fieldNamingPolicy)
      .registerTypeAdapterFactory(SampleAdapterFactory.create())
      .create();
}
origin: paypal/PayPal-Java-SDK

/**
 * Set a format for gson FIELD_NAMING_POLICY. See {@link FieldNamingPolicy}
 * 
 * @param FIELD_NAMING_POLICY
 */
public static final void setFIELD_NAMING_POLICY(
    FieldNamingPolicy FIELD_NAMING_POLICY) {
  GSON = new GsonBuilder().setPrettyPrinting()
      .setFieldNamingPolicy(FIELD_NAMING_POLICY).create();
}
origin: com.paypal.sdk/paypal-core

/**
 * Set a format for gson FIELD_NAMING_POLICY. See {@link FieldNamingPolicy}
 * 
 * @param FIELD_NAMING_POLICY
 */
public static final void setFIELD_NAMING_POLICY(
    FieldNamingPolicy FIELD_NAMING_POLICY) {
  GSON = new GsonBuilder().setPrettyPrinting()
      .setFieldNamingPolicy(FIELD_NAMING_POLICY).create();
}
origin: codepath/dagger2-example

@Provides  // Dagger will only look for methods annotated with @Provides
@Singleton
Gson provideGson() {
  GsonBuilder gsonBuilder = new GsonBuilder();
  gsonBuilder.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES);
  return gsonBuilder.create();
}
origin: stackoverflow.com

try {
     JSONObject object = new JSONObject("{\"array\":[{\"US\":\"id_123\"},{\"UK\":\"id_112\"},{\"EN\":\"id_1112\"}]}");
     GsonBuilder builder = new GsonBuilder();
     builder.registerTypeAdapter(new TypeToken<ArrayList<City>>() {}.getType(), new CityListDeserializer());
     Gson gson = builder.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create();
     List<City> cityList = gson.fromJson(String.valueOf(object), new TypeToken<ArrayList<City>>() {}.getType());
   } catch (JSONException e) {
     e.printStackTrace();
   }
origin: Pingplusplus/pingpp-java

  @Override
  public JsonElement serialize(SettleAccountRecipient recipient, Type type, JsonSerializationContext jsonSerializationContext) {
    GsonBuilder gsonBuilder = new GsonBuilder()
        .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
        .disableHtmlEscaping();

    return gsonBuilder.create().toJsonTree(recipient, type);
  }
}
origin: com.aliyun.mns/aliyun-sdk-mns

private synchronized Gson getGson() {
  if (gson == null) {
    GsonBuilder b = new GsonBuilder();
    b.setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE);
    BooleanSerializer serializer = new BooleanSerializer();
    b.registerTypeAdapter(Boolean.class, serializer);
    b.registerTypeAdapter(boolean.class, serializer);
    b.registerTypeAdapter(PushAttributes.class, new PushAttributes.PushAttributesSerializer());
    gson = b.create();
  }
  return gson;
}
origin: com.atlassian.jira.plugins/bitbucket-client

private static Gson createGson() {
  GsonBuilder builder = new GsonBuilder();
  builder.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES);
  builder.registerTypeAdapter(Date.class, new GsonDateTypeAdapter()); //to parse 2011-12-21 15:17:37
  builder.registerTypeAdapter(BitbucketPullRequestActivityInfo.class, new BitbucketPullRequestActivityEnvelopeDeserializer());
  return builder.create();
}
origin: com.microsoft.services.orc/orc-java

private Gson createGson() {
  return new GsonBuilder()
      .setFieldNamingPolicy(FieldNamingPolicy.IDENTITY)
      .registerTypeAdapter(Calendar.class, new CalendarTypeAdapter())
      .registerTypeAdapter(GregorianCalendar.class, new CalendarTypeAdapter())
      .registerTypeAdapter(byte[].class, getByteArrayTypeAdapter())
      .create();
}
com.google.gsonGsonBuildersetFieldNamingPolicy

Javadoc

Configures Gson to apply a specific naming policy to an object's field during serialization and deserialization.

Popular methods of GsonBuilder

  • create
    Creates a Gson instance based on the current configuration. This method is free of side-effects to t
  • <init>
    Constructs a GsonBuilder instance from a Gson instance. The newly constructed GsonBuilder has the sa
  • registerTypeAdapter
  • setPrettyPrinting
    Configures Gson to output Json that fits in a page for pretty printing. This option only affects Jso
  • serializeNulls
    Configure Gson to serialize null fields. By default, Gson omits all fields that are null during seri
  • disableHtmlEscaping
    By default, Gson escapes HTML characters such as < > etc. Use this option to configure Gson to pass-
  • setDateFormat
    Configures Gson to serialize Date objects according to the pattern provided. You can call this metho
  • registerTypeAdapterFactory
    Register a factory for type adapters. Registering a factory is useful when the type adapter needs to
  • registerTypeHierarchyAdapter
  • excludeFieldsWithoutExposeAnnotation
    Configures Gson to exclude all fields from consideration for serialization or deserialization that d
  • setExclusionStrategies
    Configures Gson to apply a set of exclusion strategies during both serialization and deserialization
  • enableComplexMapKeySerialization
    Enabling this feature will only change the serialized form if the map key is a complex type (i.e. no
  • setExclusionStrategies,
  • enableComplexMapKeySerialization,
  • setLenient,
  • addSerializationExclusionStrategy,
  • excludeFieldsWithModifiers,
  • serializeSpecialFloatingPointValues,
  • setVersion,
  • setFieldNamingStrategy,
  • addTypeAdaptersForDate

Popular in Java

  • Reactive rest calls using spring rest template
  • getResourceAsStream (ClassLoader)
  • getSupportFragmentManager (FragmentActivity)
  • getExternalFilesDir (Context)
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • ServerSocket (java.net)
    This class represents a server-side socket that waits for incoming client connections. A ServerSocke
  • Path (java.nio.file)
  • Connection (java.sql)
    A connection represents a link from a Java application to a database. All SQL statements and results
  • Annotation (javassist.bytecode.annotation)
    The annotation structure.An instance of this class is returned bygetAnnotations() in AnnotationsAttr
  • Servlet (javax.servlet)
    Defines methods that all servlets must implement. A servlet is a small Java program that runs within
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now