```listOf( Person( name = "foo", ...
# spring
u
Copy code
listOf(
    Person(
        name = "foo",
        age = 44,
        fooBar = "lol",
        isImportant = true,
        isNew = true
    )
)
Why does this get serialized into json as
[{"id":null,"name":"foo","age":44,"fooBar":"lol","new":true,"important":true}]
? I.e. missing the
is
prefixes? What's even worse is when I try to deserialize the same json that was just serialized, I'll get errors. Broken by default
t
jackson is mainly based on java convention,
isXXX
is the default getter method name for boolean (thanks Jakub, stealing your edit), it should work with
Copy code
listOf(
    Person(
        name = "foo",
        age = 44,
        fooBar = "lol",
        important = true,
        new = true
    )
)
k
I assume getter (and setter) convention in java world for boolean properties.
t
another option you have a bad
ObjectMapper
configuration, how are you creating it @ursus? if you have something like
Copy code
@Bean
fun objectMapper() = ObjectMapper()
you should amend that; my personal preference is to configure the mapper spring already creates for you, if you prefer to create a new one ensure kotlin module is configured
Copy code
@Bean
fun objectMapper() = ObjectMapper().findAndRegisterModule()

/* or, but I prefer the above one since jackson will scan your classpath and is smart to configure what it needs
@Bean
fun objectMapper() = jacksonObjectMapper() //this is a kotlin extension funtion
*/
with a "correct" object mapper,
isImportant
and
isNew
work as you expect