Annotation Interface JSonAttribute
- Since:
- 4.0
- Author:
- JBStrap
- See Also:
-
Optional Element Summary
Modifier and TypeOptional ElementDescriptionUse this option to specify if the field contains a Java object, which field in the JSON object should be the value from the Java class instead of the value of the field.Use this option to specify if the field contains a Java object, which field in the JSON object should be replaced with the Java class method's return value should be used for the value of the field.Sets the name of the attribute that is in the JSON object If not specified, the attribute name will be the same as the field nameThe format used when converting Date values into String.boolean
Converts the empty value (ie, empty string or list) to anull
value.If it's set totrue
, the empty values will appear asnull
in the JSON object.Sets the name of the data formatter method.
-
Element Details
-
attributeName
String attributeNameSets the name of the attribute that is in the JSON object If not specified, the attribute name will be the same as the field name- Returns:
- The name of the attribute that is in the JSON object
- Default:
- ""
-
emptyValueAsNull
boolean emptyValueAsNullConverts the empty value (ie, empty string or list) to anull
value.If it's set totrue
, the empty values will appear asnull
in the JSON object. If set tofalse
, it will be an empty value. If not set, empty values will benull
- Returns:
true
, if the empty values will be converted intonull
- Default:
- true
-
dateFormat
String dateFormatThe format used when converting Date values into String. If not specified, the default format will be used, which is "yyyy-MM-dd'T'HH:mm:ss"- Returns:
- The format used when generating JSON
- Default:
- "yyyy-MM-dd\'T\'HH:mm:ss"
-
alternativeField
String alternativeFieldUse this option to specify if the field contains a Java object, which field in the JSON object should be the value from the Java class instead of the value of the field. It is recommended to use this, if you want to place different values in the JSON object, based on an ENUM.
- Returns:
- The name of the field, that has the value, that will be in the JSON object.
- Default:
- ""
-
alternativeMethod
String alternativeMethodUse this option to specify if the field contains a Java object, which field in the JSON object should be replaced with the Java class method's return value should be used for the value of the field.
- Returns:
- The name of the field, which has the value that will be used in the JSON object.
- Default:
- ""
-
formatterMethod
String formatterMethodSets the name of the data formatter method.
Here, a method can be specified that exists in the source class, is public, and has a single parameter, and is an
Object
type. The specified method has to return with aString
type. This will be placed in the JSON object. When the method is called, the parameter will be the original field value.- Returns:
- The formatter method name, that converts the value to text.
- Default:
- ""
-