Define new getter which will return String instead of Optional.
public class Test {
Optional field = Optional.of("hello, world!");
@JsonIgnore
public Optional getField() {
return field;
}
@JsonProperty("field")
public String getFieldName() {
return field.orElse(null);
}
}