Package com.alibaba.fastjson2.annotation
Annotation Type JSONField
When the Key in the JSON does not match the property in the
Bean,
the conversion process may not meet expectations. JSONField can not only solve this problem but also implement custom requirements.-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionString[]Using multiple different field names when deserializingbooleanWhether the field is deserialized during deserialization, defaulttureSpecifyJSONReader.Features to use features when deserializingSpecifies thatObjectReaderis used when deserializingIf the field isDate, then please define the date formatbooleanSpecify theStringas the key name in JSONintThe order of the fields during serialization and output in ascending orderbooleanProperty that indicates whether a value (which may be explicit null) is expected for property during deserialization or not.booleanWhether the field is serialized during serialization, defaulttureSpecifyJSONWriter.Features to use features when serializing outputSpecifies thatObjectWriteris used when serializingbooleanIf true, serialize and deserialize the field's internal propertiesbooleanDeprecated.
-
Element Details
-
ordinal
int ordinalThe order of the fields during serialization and output in ascending order- Default:
- 0
-
name
String nameSpecify theStringas the key name in JSON- Default:
- ""
-
format
String formatIf the field isDate, then please define the date format- Default:
- ""
-
label
String label- Default:
- ""
-
serialize
boolean serializeWhether the field is serialized during serialization, defaultture- Default:
- true
-
deserialize
boolean deserializeWhether the field is deserialized during deserialization, defaultture- Default:
- true
-
unwrapped
boolean unwrappedIf true, serialize and deserialize the field's internal properties- Default:
- false
-
alternateNames
String[] alternateNamesUsing multiple different field names when deserializing- Default:
- {}
-
writeUsing
Deprecated.Specifies thatObjectWriteris used when serializing- Default:
- java.lang.Void.class
-
serializeUsing
Class serializeUsingSpecifies thatObjectWriteris used when serializing- Default:
- java.lang.Void.class
-
deserializeUsing
Class deserializeUsingSpecifies thatObjectReaderis used when deserializing- Default:
- java.lang.Void.class
-
deserializeFeatures
JSONReader.Feature[] deserializeFeaturesSpecifyJSONReader.Features to use features when deserializing- Default:
- {}
-
serializeFeatures
JSONWriter.Feature[] serializeFeaturesSpecifyJSONWriter.Features to use features when serializing output- Default:
- {}
-
value
boolean value- Default:
- false
-
defaultValue
String defaultValue- Since:
- 1.2.61
- Default:
- ""
-
locale
String locale- Default:
- ""
-
schema
String schema- Default:
- ""
-
jsonDirect
boolean jsonDirect- Default:
- false
-
required
boolean requiredProperty that indicates whether a value (which may be explicit null) is expected for property during deserialization or not. If expected,ObjectReadershould indicate this as a validity problem (usually by throwing an exception, but this may be sent via problem handlers that can try to rectify the problem, for example, by supplying a default value).- Since:
- 2.0.20
- Default:
- false
-