| AndBase开发框架 1.6

- 首页
- 相关页面
- 命名空间
- 类
- 文件

- 类列表
- 类索引
- 类继承关系
- 类成员

全部 类 命名空间 文件 函数 变量 枚举值 页
Public 属性 | 静态 Private 成员函数 | 所有成员列表
com.google.gson.FieldNamingPolicy 枚举类型参考
类 com.google.gson.FieldNamingPolicy 继承关系图:

## Public 属性
| IDENTITY
| UPPER_CAMEL_CASE
| UPPER_CAMEL_CASE_WITH_SPACES
| LOWER_CASE_WITH_UNDERSCORES
| LOWER_CASE_WITH_DASHES

## 静态 Private 成员函数
static String | separateCamelCase (String name, String separator)
static String | upperCaseFirstLetter (String name)
static String | modifyString (char firstCharacter, String srcString, int indexOfSubstring)

## 额外继承的成员函数
Public 成员函数 继承自 com.google.gson.FieldNamingStrategy
String | translateName (Field f)

## 详细描述

An enumeration that defines a few standard naming conventions for JSON field names. This enumeration should be used in conjunction with com.google.gson.GsonBuilder to configure a com.google.gson.Gson instance to properly translate Java field names into the desired JSON field names.

作者
  Inderjeet Singh
  Joel Leitch

## 成员函数说明

static String com.google.gson.FieldNamingPolicy.modifyString | ( | char | firstCharacter,
|  | String | srcString,
|  | int | indexOfSubstring
| ) |  |
| inline static private

static String com.google.gson.FieldNamingPolicy.separateCamelCase | ( | String | name,
|  | String | separator
| ) |  |
| inline static private

Converts the field name that uses camel-case define word separation into separate words that are separated by the provided

separatorString

.

static String com.google.gson.FieldNamingPolicy.upperCaseFirstLetter | ( | String | name | ) |
| inline static private

Ensures the JSON field names begins with an upper case letter.

## 类成员变量说明

com.google.gson.FieldNamingPolicy.IDENTITY

初始值:
=() {
public String translateName(Field f) {
return f.getName();
}
}

Using this naming policy with Gson will ensure that the field name is unchanged.

com.google.gson.FieldNamingPolicy.LOWER_CASE_WITH_DASHES

初始值:
=() {
public String translateName(Field f) {
return separateCamelCase(f.getName(), "-").toLowerCase();
}
}

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":

- someFieldName —> some-field-name
- _someFieldName —> _some-field-name
- aStringField —> a-string-field
- aURL —> a-u-r-l

Using dashes in JavaScript is not recommended since dash is also used for a minus sign in expressions. This requires that a field named with dashes is always accessed as a quoted property like

myobject['my-field']

. Accessing it as an object field

myobject.my-field

will result in an unintended javascript expression.

自从
  1.4

com.google.gson.FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES

初始值:
=() {
public String translateName(Field f) {
return separateCamelCase(f.getName(), "_").toLowerCase();
}
}

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":

- someFieldName —> some_field_name
- _someFieldName —> _some_field_name
- aStringField —> a_string_field
- aURL —> a_u_r_l

com.google.gson.FieldNamingPolicy.UPPER_CAMEL_CASE

初始值:
=() {
public String translateName(Field f) {
return upperCaseFirstLetter(f.getName());
}
}

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":

- someFieldName —> SomeFieldName
- _someFieldName —> _SomeFieldName

com.google.gson.FieldNamingPolicy.UPPER_CAMEL_CASE_WITH_SPACES

初始值:
=() {
public String translateName(Field f) {
return upperCaseFirstLetter(separateCamelCase(f.getName(), " "));
}
}

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":

- someFieldName —> Some Field Name
- _someFieldName —> _Some Field Name

自从
  1.4

枚举说明文档从下列文件生成:

- src/com/google/gson/FieldNamingPolicy.java