public enum PropertyNamingStrategy extends java.lang.Enum<PropertyNamingStrategy>
This enum provides various naming strategies that can be used to transform Java field names to different JSON field naming conventions. For example, camelCase can be transformed to snake_case, kebab-case, or other formats.
Example usage:
// Using snake_case naming strategy
PropertyNamingStrategy.SnakeCase.fieldName("userName"); // returns "user_name"
// Using PascalCase naming strategy
PropertyNamingStrategy.PascalCase.fieldName("userName"); // returns "UserName"
| Enum Constant and Description |
|---|
CamelCase |
CamelCase1x
for fastjson 1.x compatible
|
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 (-).
|
LowerCase |
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 (-).
|
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 (.).
|
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 (_).
|
NeverUseThisValueExceptDefaultValue |
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.
|
SnakeCase |
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 (-).
|
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 (-).
|
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.
|
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 (_).
|
UpperCase |
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 (-).
|
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 (.).
|
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 (_).
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
fieldName(java.lang.String name)
Transforms the given field name according to this naming strategy.
|
static PropertyNamingStrategy |
of(java.lang.String strategy)
Returns the PropertyNamingStrategy enum constant with the specified name.
|
static java.lang.String |
snakeToCamel(java.lang.String name)
Converts a snake_case string to camelCase.
|
static PropertyNamingStrategy |
valueOf(java.lang.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.
|
public static final PropertyNamingStrategy CamelCase
public static final PropertyNamingStrategy CamelCase1x
public static final PropertyNamingStrategy PascalCase
public static final PropertyNamingStrategy SnakeCase
public static final PropertyNamingStrategy UpperCase
public static final PropertyNamingStrategy UpperCamelCaseWithSpaces
public static final PropertyNamingStrategy UpperCamelCaseWithUnderScores
public static final PropertyNamingStrategy UpperCamelCaseWithDashes
public static final PropertyNamingStrategy UpperCamelCaseWithDots
public static final PropertyNamingStrategy KebabCase
public static final PropertyNamingStrategy UpperCaseWithUnderScores
public static final PropertyNamingStrategy UpperCaseWithDashes
public static final PropertyNamingStrategy UpperCaseWithDots
public static final PropertyNamingStrategy LowerCase
public static final PropertyNamingStrategy LowerCaseWithUnderScores
public static final PropertyNamingStrategy LowerCaseWithDashes
public static final PropertyNamingStrategy LowerCaseWithDots
public static final PropertyNamingStrategy NeverUseThisValueExceptDefaultValue
public static PropertyNamingStrategy[] values()
for (PropertyNamingStrategy c : PropertyNamingStrategy.values()) System.out.println(c);
public static PropertyNamingStrategy valueOf(java.lang.String name)
name - the name of the enum constant to be returned.java.lang.IllegalArgumentException - if this enum type has no constant with the specified namejava.lang.NullPointerException - if the argument is nullpublic java.lang.String fieldName(java.lang.String name)
name - the original field name in Java (typically camelCase)public static java.lang.String snakeToCamel(java.lang.String name)
For example:
name - the snake_case string to convertpublic static PropertyNamingStrategy of(java.lang.String strategy)
The string matching is case-insensitive for common aliases:
Other strategy names are matched case-sensitively against the enum constant names.strategy - the name of the strategy to find, or null/empty to return null