-
-
Notifications
You must be signed in to change notification settings - Fork 180
Closed
Labels
is-prefixIssues relating to is-prefixed fieldsIssues relating to is-prefixed fields
Milestone
Description
Hi,
I'm experiencing issues with a boolean property which name starts with 'is'.
While the getter doesn't get prefixed by kotlin, it seems that jackson still strips away 'is' as though it was a prefix. The resulting json doesn't contain the 'is', and deserialization fails.
This test illustrates the problem:
class SerializationTest {
@Test
fun testIsBool() {
val mapper = ObjectMapper()
mapper.registerModule(KotlinModule())
val example = IsBoolExample(true)
val json = mapper.writeValueAsString(example)
// json contains: {"trueOrFalse":true}
val deserialized = mapper.readValue(json, IsBoolExample::class.java)
Assert.assertEquals(example.isTrueOrFalse, deserialized.isTrueOrFalse)
}
}
class IsBoolExample(val isTrueOrFalse: Boolean)
This fails on mapper.readValue(..)
with:
com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of com.bol.service.reptile.spring.IsBoolExample: no suitable constructor found, can not deserialize from Object value (missing default constructor or creator, or perhaps need to add/enable type information?)
at [Source: {"trueOrFalse":true}; line: 1, column: 2]
reith, yami12376, raderio, fabriciolemos, jdorleans and 63 more
Metadata
Metadata
Assignees
Labels
is-prefixIssues relating to is-prefixed fieldsIssues relating to is-prefixed fields