Annotation Type B2Json.optional


  • @Retention(RUNTIME)
    @Target(FIELD)
    public static @interface B2Json.optional
    Field annotation that says a field is optional. The value will almost always be included when serializing, with two exceptions. If omitNull is true and the value is null, it will be left out of the serialized representation. Similarly, if omitZero is true and the value is zero, it will be left out of the serialized representation. Note that both omitNull and omitZero default to false. A B2JsonException is thrown when omitNull is set to true on a primitive field; primitives are not nullable objects so omitNull does not apply. Similarly, a B2JsonException is thrown when omitZero is set to true on a field that's either non-numeric, non-primitive, or not built into B2Json. Note that they can't both be used on the same field because one only works on non-primitive fields and the other only works on primitive fields. When deserializing, null/false/0 will be passed to the constructor if the value is not present in the JSON.
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      boolean omitNull  
      boolean omitZero  
    • Element Detail

      • omitNull

        boolean omitNull
        Default:
        false
      • omitZero

        boolean omitZero
        Default:
        false