Pihentagy
03/14/2024, 2:28 PMdata class MyClass @JsonCreator constructor (
var changedAt: Date,
var from: Int,
var to: Int,
var percentChanged: Int,
var levelUsed: Int,
)
Sam
03/14/2024, 2:34 PMSam
03/14/2024, 2:34 PM@JsonCreator
annotation.Sam
03/14/2024, 2:34 PMPihentagy
03/14/2024, 2:35 PMPihentagy
03/14/2024, 2:40 PMPihentagy
03/14/2024, 2:40 PMSam
03/14/2024, 2:42 PMjackson-module-kotlin
dependency, it also needs to be registered when you create the object mapper. Maybe that's missing?Sam
03/14/2024, 2:43 PMval mapper = jacksonObjectMapper()
, that's using the Kotlin module and you're good 👍. But if you just have val mapper = ObjectMapper()
, with no extra Kotlin module being registered, that could definitely explain the issues you're seeing.Sam
03/14/2024, 2:44 PMPihentagy
03/14/2024, 2:44 PMSam
03/14/2024, 2:44 PMPihentagy
03/14/2024, 2:44 PMPihentagy
03/14/2024, 2:45 PMSam
03/14/2024, 2:45 PMPihentagy
03/14/2024, 2:46 PMPihentagy
03/14/2024, 2:46 PMSam
03/14/2024, 2:50 PMSam
03/14/2024, 2:50 PM@JdbcTypeCode
annotation, but I've not done it myselfSam
03/14/2024, 2:51 PMPihentagy
03/14/2024, 2:53 PMSam
03/14/2024, 2:54 PM@JdbcTypeCode(SqlTypes.JSON)
Pihentagy
03/14/2024, 2:56 PMPihentagy
03/14/2024, 3:09 PMthanksforallthefish
03/14/2024, 3:09 PMorg.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration
you should need to define custom module and/or special configuration, eg if you want to configure the kotlin module:
@Bean
fun kotlinModule(): KotlinModule = KotlinModule.Builder()
.configure(KotlinFeature.NullIsSameAsDefault, enabled = true)
.build()
Pihentagy
03/14/2024, 3:11 PMthanksforallthefish
03/14/2024, 3:14 PM@Bean
fun objectMapper() = jacksonObjectMapper()
completely overrides the whole logic spring gives you to configure the object mapper flexibly: https://docs.spring.io/spring-boot/docs/current/reference/html/howto.html#howto.spring-mvc.customize-jackson-objectmapperthanksforallthefish
03/14/2024, 3:16 PMObjectMapper().findAndRegisterModules()
over jacksonObjectMapper()
, jackson will scan the classpath and preconfigure the object mapper accordingly