Open
Description
When there is a case class
with BeanProperty
-annotated field, the following code sometimes generates JSON with duplicate fields. For example, pId
field gets serialized twice, as pId
and pid
.
private val mapper = {
val objectMapper = new ObjectMapper with ScalaObjectMapper
objectMapper.registerModule(DefaultScalaModule)
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL)
objectMapper
}
def toJson[A <: AnyRef](a: A): String = {
mapper.writeValueAsString(a)
}
It's impossible to remove BeanProperty
annotation, because it's needed by another library. Also it's impossible to set BeanProperty
on every field and remove ScalaObjectMapper
, as such changes are numerous and would likely result in other compatibility issues. What's the proper way to fix this problem?
Metadata
Metadata
Assignees
Labels
No labels