com.google.gson.GsonBuilder to configure a
com.google.gson.Gson instance to properly translate Java field names into the desired
JSON field names.
| Modifier and Type | Field and Description |
|---|---|
| public static final FieldNamingPolicy | IDENTITY
Using this naming policy with Gson will ensure that the field name is unchanged. |
| public static final 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 (-). |
| public static final FieldNamingPolicy | LOWER_CASE_WITH_DOTS
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 dot (.). |
| public static final 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 (_). |
| public static final 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. |
| public static final 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 static final FieldNamingPolicy | UPPER_CASE_WITH_UNDERSCORES
Using this naming policy with Gson will modify the Java Field name from its camel cased form to an upper case field name where each word is separated by an underscore (_). |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv static String | separateCamelCase(String name, char separator)
Converts the field name that uses camel-case define word separation into separate words that
are separated by the provided |
| pack-priv static String | |
| public static FieldNamingPolicy | |
| public static FieldNamingPolicy[] |
| IDENTITY | back to summary |
|---|---|
| public static final FieldNamingPolicy IDENTITY Using this naming policy with Gson will ensure that the field name is unchanged. | |
| LOWER_CASE_WITH_DASHES | back to summary |
|---|---|
| public static final 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 (-). Here are 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.
| |
| LOWER_CASE_WITH_DOTS | back to summary |
|---|---|
| public static final FieldNamingPolicy LOWER_CASE_WITH_DOTS 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 dot (.). Here are 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.
| |
| LOWER_CASE_WITH_UNDERSCORES | back to summary |
|---|---|
| public static final 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 (_). Here are a few examples of the form "Java Field Name" ---> "JSON Field Name":
| |
| UPPER_CAMEL_CASE | back to summary |
|---|---|
| public static final 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. Here are a few examples of the form "Java Field Name" ---> "JSON Field Name":
| |
| UPPER_CAMEL_CASE_WITH_SPACES | back to summary |
|---|---|
| public static final 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. Here are a few examples of the form "Java Field Name" ---> "JSON Field Name":
| |
| UPPER_CASE_WITH_UNDERSCORES | back to summary |
|---|---|
| public static final FieldNamingPolicy UPPER_CASE_WITH_UNDERSCORES Using this naming policy with Gson will modify the Java Field name from its camel cased form to an upper case field name where each word is separated by an underscore (_). Here are a few examples of the form "Java Field Name" ---> "JSON Field Name":
| |
| FieldNamingPolicy | back to summary |
|---|---|
| private FieldNamingPolicy() | |
| separateCamelCase | back to summary |
|---|---|
| pack-priv static String separateCamelCase(String name, char separator) Converts the field name that uses camel-case define word separation into separate words that
are separated by the provided | |
| upperCaseFirstLetter | back to summary |
|---|---|
| pack-priv static String upperCaseFirstLetter(String s) Ensures the JSON field names begins with an upper case letter. | |
| valueOf | back to summary |
|---|---|
| public static FieldNamingPolicy valueOf(String name) | |
| values | back to summary |
|---|---|
| public static FieldNamingPolicy[] values() | |