https://kotlinlang.org logo
Title
v

Volkan Nezir

07/09/2019, 1:55 PM
Hi - is there a way to override the body lens serialisation setting to not write empty lists as nulls?
Nulls.AS_EMPTY
d

dave

07/09/2019, 1:56 PM
you can define your own Jackson object using the template here:
object Jackson : ConfigurableJackson(KotlinModule()
    .asConfigurable()
    .withStandardMappings()
    .done()
    .disableDefaultTyping()
    .configure(FAIL_ON_UNKNOWN_PROPERTIES, false)
    .configure(FAIL_ON_IGNORED_PROPERTIES, false)
    .configure(USE_BIG_DECIMAL_FOR_FLOATS, true)
    .configure(USE_BIG_INTEGER_FOR_INTS, true)
)
(the last lines there are the Jackson mapper config)
(assuming Jackson)
v

Volkan Nezir

07/09/2019, 2:01 PM
yes correct - thank you. so if I include this definition, is this automatically picked up by http4k?
d

dave

07/09/2019, 2:03 PM
no - when you define your own Jackson instance you will need to import everything from there instead of from our Jackson
object MyJackson : ConfigurableJackson(KotlinModule()
    .asConfigurable()
    .withStandardMappings()
    .done()
    .disableDefaultTyping()
    .configure(FAIL_ON_UNKNOWN_PROPERTIES, false)
    .configure(FAIL_ON_IGNORED_PROPERTIES, false)
    .configure(USE_BIG_DECIMAL_FOR_FLOATS, true)
    .configure(USE_BIG_INTEGER_FOR_INTS, true)
)
then
import org.bob.MyJackson.auto
v

Volkan Nezir

07/09/2019, 2:06 PM
oh I see ok - thanks!