fun main(args: Array<String>) {
val mapper = ObjectMapper().apply {
registerModule(Jdk8Module())
registerModule(KotlinModule())
}
println(mapper.writeValueAsString(SomePatch(null, Optional.empty(), Optional.of("hello"))))
println(mapper.readValue("{\"y\":null,\"z\":\"hello\"}", SomePatch::class.java))
}
@JsonInclude(JsonInclude.Include.NON_NULL)
data class SomePatch(
val x: Optional<Int>?,
val y: Optional<String>?,
val z: Optional<String>?
)
output for version 2.9.6:
output for version 2.9.7:
x absent in json but deserialize in Optional.empty