| java.lang.Object | ||
| ↳ | java.lang.Enum<E extends java.lang.Enum<E>> | |
| ↳ | com.google.gson.FieldNamingPolicy | |
An enumeration that defines a few standard naming conventions for JSON field names.
This enumeration should be used in conjunction with GsonBuilder
to configure a Gson instance to properly translate Java field
names into the desired JSON field names.
| Enum Values | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| FieldNamingPolicy | IDENTITY | Using this naming policy with Gson will ensure that the field name is unchanged. | |||||||||
| FieldNamingPolicy | LOWER_CASE_WITH_DASHES | Using this naming policy with Gson will modify the Java Field name from its camel cased form to a lower case field name where each word is separated by a dash (-). | |||||||||
| FieldNamingPolicy | LOWER_CASE_WITH_UNDERSCORES | Using this naming policy with Gson will modify the Java Field name from its camel cased form to a lower case field name where each word is separated by an underscore (_). | |||||||||
| FieldNamingPolicy | UPPER_CAMEL_CASE | Using this naming policy with Gson will ensure that the first "letter" of the Java field name is capitalized when serialized to its JSON form. | |||||||||
| FieldNamingPolicy | UPPER_CAMEL_CASE_WITH_SPACES | Using this naming policy with Gson will ensure that the first "letter" of the Java field name is capitalized when serialized to its JSON form and the words will be separated by a space. | |||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| static FieldNamingPolicy | valueOf(String name) | ||||||||||
| final static FieldNamingPolicy[] | values() | ||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Enum
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
com.google.gson.FieldNamingStrategy
| |||||||||||
From interface
java.lang.Comparable
| |||||||||||
Using this naming policy with Gson will ensure that the field name is unchanged.
Using this naming policy with Gson will modify the Java Field name from its camel cased form to a lower case field name where each word is separated by a dash (-).
Here's a few examples of the form "Java Field Name" ---> "JSON Field Name":
myobject['my-field']. Accessing it as an object field
myobject.my-field will result in an unintended javascript expression.Using this naming policy with Gson will modify the Java Field name from its camel cased form to a lower case field name where each word is separated by an underscore (_).
Here's a few examples of the form "Java Field Name" ---> "JSON Field Name":
Using this naming policy with Gson will ensure that the first "letter" of the Java field name is capitalized when serialized to its JSON form.
Here's a few examples of the form "Java Field Name" ---> "JSON Field Name":
Using this naming policy with Gson will ensure that the first "letter" of the Java field name is capitalized when serialized to its JSON form and the words will be separated by a space.
Here's a few examples of the form "Java Field Name" ---> "JSON Field Name":