Description
A method like this
public Optional<Boolean> isUsed() {
return Optional.ofNullable(used);
}
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
public Boolean isUsed() {
return used;
}
What also works is annotating it. However, this then produces a field isUsed
(it does not strip the is
as it generally happens for boolean properties). Annotating a Optional<String> get...
method with @JsonProperty
works as expected with stripping the get
.
@JsonProperty
public Optional<Boolean> isUsed() {
return Optional.ofNullable(used);
}
So to get the "standard" boolean field behavior it needs
@JsonProperty("used")
public Optional<Boolean> isUsed() {
return Optional.ofNullable(used);
}
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 behavior