Package com.alibaba.fastjson2
Enum PropertyNamingStrategy
- java.lang.Object
-
- java.lang.Enum<PropertyNamingStrategy>
-
- com.alibaba.fastjson2.PropertyNamingStrategy
-
- All Implemented Interfaces:
Serializable,Comparable<PropertyNamingStrategy>
public enum PropertyNamingStrategy extends Enum<PropertyNamingStrategy>
An enumeration that defines a few standard naming conventions for JSON field names.- Since:
- 1.2.15
-
-
Enum Constant Summary
Enum Constants Enum Constant Description CamelCaseCamelCase1xfor fastjson 1.x compatibleKebabCaseUsing this naming policy with FASTJSON 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 (-).LowerCaseLowerCaseWithDashesUsing this naming policy with FASTJSON 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 (-).LowerCaseWithDotsUsing this naming policy with FASTJSON 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 (.).LowerCaseWithUnderScoresUsing this naming policy with FASTJSON 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 (_).NeverUseThisValueExceptDefaultValuePascalCaseUsing this naming policy with FASTJSON will ensure that the first "letter" of the Java field name is capitalized when serialized to its JSON form.SnakeCaseUpperCamelCaseWithDashesUsing this naming policy with FASTJSON 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 dash (-).UpperCamelCaseWithDotsUsing this naming policy with FASTJSON 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 dash (-).UpperCamelCaseWithSpacesUsing this naming policy with FASTJSON 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.UpperCamelCaseWithUnderScoresUsing this naming policy with FASTJSON 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 an underscore (_).UpperCaseUpperCaseWithDashesUsing this naming policy with FASTJSON will modify the Java Field name from its camel cased form to an upper case field name where each word is separated by a dash (-).UpperCaseWithDotsUsing this naming policy with FASTJSON will modify the Java Field name from its camel cased form to an upper case field name where each word is separated by a dot (.).UpperCaseWithUnderScoresUsing this naming policy with FASTJSON 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 (_).
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringfieldName(String name)static StringsnakeToCamel(String name)static PropertyNamingStrategyvalueOf(String name)Returns the enum constant of this type with the specified name.static PropertyNamingStrategy[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
CamelCase
public static final PropertyNamingStrategy CamelCase
-
CamelCase1x
public static final PropertyNamingStrategy CamelCase1x
for fastjson 1.x compatible
-
PascalCase
public static final PropertyNamingStrategy PascalCase
Using this naming policy with FASTJSON 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": someFieldName ---> SomeFieldName _someFieldName ---> _SomeFieldName
-
SnakeCase
public static final PropertyNamingStrategy SnakeCase
-
UpperCase
public static final PropertyNamingStrategy UpperCase
-
UpperCamelCaseWithSpaces
public static final PropertyNamingStrategy UpperCamelCaseWithSpaces
Using this naming policy with FASTJSON 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": someFieldName ---> Some Field Name _someFieldName ---> _Some Field Name- Since:
- 2.0.7
-
UpperCamelCaseWithUnderScores
public static final PropertyNamingStrategy UpperCamelCaseWithUnderScores
Using this naming policy with FASTJSON 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 an underscore (_). Here are a few examples of the form "Java Field Name" ---> "JSON Field Name": someFieldName ---> Some_Field_Name _someFieldName ---> _Some_Field_Name- Since:
- 2.0.7
-
UpperCamelCaseWithDashes
public static final PropertyNamingStrategy UpperCamelCaseWithDashes
Using this naming policy with FASTJSON 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 dash (-). Here are a few examples of the form "Java Field Name" ---> "JSON Field Name": someFieldName ---> Some-Field-Name _someFieldName ---> _Some-Field-Name- Since:
- 2.0.7
-
UpperCamelCaseWithDots
public static final PropertyNamingStrategy UpperCamelCaseWithDots
Using this naming policy with FASTJSON 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 dash (-). Here are a few examples of the form "Java Field Name" ---> "JSON Field Name": someFieldName ---> Some-Field-Name _someFieldName ---> _Some-Field-Name- Since:
- 2.0.7
-
KebabCase
public static final PropertyNamingStrategy KebabCase
Using this naming policy with FASTJSON 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": 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.
-
UpperCaseWithUnderScores
public static final PropertyNamingStrategy UpperCaseWithUnderScores
Using this naming policy with FASTJSON 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": someFieldName ---> SOME_FIELD_NAME _someFieldName ---> _SOME_FIELD_NAME aStringField ---> A_STRING_FIELD aURL ---> A_U_R_L- Since:
- 2.0.7
-
UpperCaseWithDashes
public static final PropertyNamingStrategy UpperCaseWithDashes
Using this naming policy with FASTJSON will modify the Java Field name from its camel cased form to an upper 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": someFieldName ---> SOME-FIELD-NAME _someFieldName ---> _SOME-FIELD-NAME aStringField ---> A-STRING-FIELD aURL ---> A-U-R-L- Since:
- 2.0.8
-
UpperCaseWithDots
public static final PropertyNamingStrategy UpperCaseWithDots
Using this naming policy with FASTJSON will modify the Java Field name from its camel cased form to an upper 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": someFieldName ---> SOME.FIELD.NAME _someFieldName ---> _SOME.FIELD.NAME aStringField ---> A.STRING.FIELD aURL ---> A.U.R.L- Since:
- 2.0.8
-
LowerCase
public static final PropertyNamingStrategy LowerCase
-
LowerCaseWithUnderScores
public static final PropertyNamingStrategy LowerCaseWithUnderScores
Using this naming policy with FASTJSON 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": someFieldName ---> some_field_name _someFieldName ---> _some_field_name aStringField ---> a_string_field aURL ---> a_u_r_l- Since:
- 2.0.7
-
LowerCaseWithDashes
public static final PropertyNamingStrategy LowerCaseWithDashes
Using this naming policy with FASTJSON 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": 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.- Since:
- 2.0.7
-
LowerCaseWithDots
public static final PropertyNamingStrategy LowerCaseWithDots
Using this naming policy with FASTJSON 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": someFieldName ---> some.field.name _someFieldName ---> _some.field.name aStringField ---> a.string.field aURL ---> a.u.r.l Using dots in JavaScript is not recommended since dot is also used for a member sign in expressions. This requires that a field named with dots 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.- Since:
- 2.0.7
-
NeverUseThisValueExceptDefaultValue
public static final PropertyNamingStrategy NeverUseThisValueExceptDefaultValue
-
-
Method Detail
-
values
public static PropertyNamingStrategy[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (PropertyNamingStrategy c : PropertyNamingStrategy.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static PropertyNamingStrategy valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
-