Annotation Type JsonAttribute


  • @Target({FIELD,METHOD,PARAMETER})
    @Retention(CLASS)
    public @interface JsonAttribute
    Compile time property configuration. Specify custom property for processing specific properties. Eg. different property name in JSON, ignore this property, etc...
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      java.lang.String[] alternativeNames
      Multiple different incoming JSON properties can be deserialized into same POJO property.
      java.lang.Class converter
      Custom property converter.
      boolean hashMatch
      Use only hash match for detecting incoming property.
      boolean ignore
      Should this property be read/written in JSON.
      JsonAttribute.IncludePolicy includeToMinimal
      Allows for fine tuning minimal serialization object format.
      int index
      Specify index order during serialization.
      boolean mandatory
      When mandatory is enabled, property must always exist in incoming JSON.
      java.lang.String name
      Property name in JSON.
      boolean nullable
      Can this field be nullable.
      CompiledJson.TypeSignature typeSignature
      Abstract types used as properties by default include type signature information so they can be properly deserialized.
    • Element Detail

      • ignore

        boolean ignore
        Should this property be read/written in JSON.
        Returns:
        true for ignored property
        Default:
        false
      • mandatory

        boolean mandatory
        When mandatory is enabled, property must always exist in incoming JSON. If property is missing during parsing an IOException will be thrown.
        Mandatory does not mean property will always be included in JSON, but this can be enforced either by using full serialization on object format, array format, or includeToMinimal setting for minimal serialization.
        Returns:
        true for mandatory property
        Default:
        false
      • nullable

        boolean nullable
        Can this field be nullable. This will omit null checks for micro performance boost (reduced branching).
        Returns:
        check for null values
        Default:
        true
      • name

        java.lang.String name
        Property name in JSON. When property name in JSON differs from this property name. Eg. "my_property" for public String myProperty;
        Returns:
        JSON property name
        Default:
        ""
      • index

        int index
        Specify index order during serialization. -1 implies default order
        Returns:
        order when defined
        Default:
        -1
      • hashMatch

        boolean hashMatch
        Use only hash match for detecting incoming property. DSL-JSON by default matches properties only by hash value. If object contains multiple properties with same hash value additional checks are performed. Those checks can be enabled always by setting hashMatch to false.
        Returns:
        should only hashMatch be used
        Default:
        true
      • alternativeNames

        java.lang.String[] alternativeNames
        Multiple different incoming JSON properties can be deserialized into same POJO property. This is useful during model changes or for coping with casing issues. Eg. "my_property", "myProperty", "MyProperty" can all be deserialized into public String myProperty;
        Returns:
        alternative JSON property names
        Default:
        {}
      • converter

        java.lang.Class converter
        Custom property converter. Unlike @JsonConverter which specifies converter for type, this converter specifies conversion only for this property. This can be used for simple formatting or for coping with "invalid" JSON.
        Returns:
        converter used for this property
        Default:
        com.dslplatform.json.JsonAttribute.class
      • typeSignature

        CompiledJson.TypeSignature typeSignature
        Abstract types used as properties by default include type signature information so they can be properly deserialized. Type signature is included with as additional "$type":"actual.type.name" property (at the start of the object). To disable inclusion of $type attribute, set this property to EXCLUDE. This property overrides the value set on @CompiledJson
        Returns:
        should include type signature in JSON
        Default:
        com.dslplatform.json.CompiledJson.TypeSignature.DEFAULT
      • includeToMinimal

        JsonAttribute.IncludePolicy includeToMinimal
        Allows for fine tuning minimal serialization object format. By default only properties with non default values will be included during serialization for such configuration. To always include some properties in output JSON this settings can be set to ALWAYS.
        While mandatory will require that property exists during parsing, this complements the feature so that property always exist in output JSON.
        Returns:
        minimal serialization object format policy for this property
        Default:
        com.dslplatform.json.JsonAttribute.IncludePolicy.NON_DEFAULT