-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Optional<Boolean>
is not recognized as boolean field
#3836
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
Comments
Hmmh. Yes, I can see this occurring. And I can see why is non-intuitive. The challenge is that of core databind recognizing structure type that it does not directly support. This might be possible to recognize given |
Although this is correctly filed here wrt initial symptom, the fix (if any) needs to go in |
Ok so the location for the fix is method
where we need to change things a bit. But it seems pretty much doable. |
Optional<Boolean>
is not recognized as boolean field
Fixed, tested with Actually will verify in |
A method like this
does not seem to get automatically recognized by Jackson as a field to include for serialization, meaning that it does not appear in the serialized JSON at all.
Changing it to this works since it is now a standard boolean return type
What also works is annotating it. However, this then produces a field
isUsed
(it does not strip theis
as it generally happens for boolean properties). Annotating aOptional<String> get...
method with@JsonProperty
works as expected with stripping theget
.So to get the "standard" boolean field behavior it needs
Any
get
methods are recognized by default, so I would think this is an issue specific to boolean properties.I should note that this has been run with
jackson-datatype-jdk8
/-annotations
/-core
v2.13.3 as well as v2.15.0-rc1, both with same behaviorThe text was updated successfully, but these errors were encountered: