Annotation Type JSONElement


@Documented
@Retention(RUNTIME)
@Target(FIELD)
public @interface JSONElement
Identifies a JSON element mapping. Only required if a Field name is different than the mapped JSON element's key, or if the value should be set or retrieved by a specified method
Author:
Jim Earley (xml.jim@gmail.com)
  • Optional Element Summary

    Optional Elements
    Modifier and Type Optional Element Description
    String getterMethod
    Specifies a getter method to use to retrieve a Class value to be set in a JSON value.
    String key
    Specifies the JSON key to use.
    String setterMethod
    Specifies a setter method to use to apply the JSON value to the Class value.
  • Element Details

    • key

      String key
      Specifies the JSON key to use. Only required if the field name is different than the JSON element's key.
      Returns:
      the JSON key mapped to this field. If empty, the Field name will be used, otherwise the key value will be used.
      Default:
      ""
    • setterMethod

      String setterMethod
      Specifies a setter method to use to apply the JSON value to the Class value. Only required if the JSONValue should not be set directly to the Field By default, the value is empty indicating that the value should be applied to the Field's set() method. If the setterMethod value is set, then the JSONValue is applied to the method.

      NOTE: The method must be public and only accept one parameter, or it will throw a JSONConversionException

      Returns:
      the methodName, or an empty String (default).

      Default:
      ""
    • getterMethod

      String getterMethod
      Specifies a getter method to use to retrieve a Class value to be set in a JSON value. Only required if the value should not be retrieved directly from the field.

      NOTE: The method must be public and contain no parameters with a return parameter (can't be void), or a JSONConversionException will be thrown

      Returns:
      Default:
      ""