-
-
Notifications
You must be signed in to change notification settings - Fork 143
Closed
Milestone
Description
If Afterburner (jackson-module-afterburner
) is registered on an ObjectMapper before DefaultScalaModule
, it interferes with (at least) how None
is serialized when Include.NON_NULL
is in play.
case class A(foo: Option[String] = None)
class B {
@JsonProperty val foo: Option[String] = None
}
val objectMapper = new ObjectMapper()
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL)
objectMapper.registerModule(new AfterburnerModule)
objectMapper.registerModule(DefaultScalaModule)
val caseClassJson = objectMapper.writeValueAsString(A())
val objectJson = objectMapper.writeValueAsString(new B())
val anonymousObjectJson = objectMapper.writeValueAsString(new {
@JsonProperty val foo: Option[String] = None
})
Expected:
caseClassJson == "{}"
objectJson == "{}"
anonymousObjectJson == "{}"
Actual:
caseClassJson == """{ "foo": null }"""
objectJson == """{ "foo": null }"""
anonymousObjectJson == "{}"
Metadata
Metadata
Assignees
Labels
No labels