Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Confusion about JsonbNillable default value #74

Open
jansupol opened this issue Mar 25, 2018 · 2 comments
Open

Confusion about JsonbNillable default value #74

jansupol opened this issue Mar 25, 2018 · 2 comments

Comments

@jansupol
Copy link
Owner

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.

@jansupol
Copy link
Owner Author

jansupol commented Apr 4, 2018

@m0mus Commented
It's an error in javadoc. It should say:

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

The general rule is that smaller scope annotation takes precedence over the bigger scope annotation. So , it you case @JsonbProperty on field overrides @JsonbNillable on type.

@jansupol
Copy link
Owner Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant