Skip to content

Confusion about JsonbNillable default value #74

@jansupol

Description

@jansupol

Quoting from Javadoc of annotation JsonbNillable:

In case of false, fields will not be serialized (default behaviour).

This sounds as if the default value of the annotation is false. However, the actual default value is true:

boolean value() default true;

Maybe the "default behaviour" refers to property serialization when no JsonbNillable annotation is present at class level, but this is rather confusing to the reader.

Moreover, it is not quite clear which of JsonbNillable and JsonbProperty takes precedence. Consider this example:

@JsonbNillable
public void Foo {

     @JsonbProperty("the_value")
     private String theValue;
}

Running a test with Yasson shows that the nillable = false default of JsonbProperty takes precedence over the class level annotation. This complies with Section 4.3 of the spec, but this behaviour cannot be gathered from the Javadoc of the two annotation classes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions