
tech.harmonysoft.oss.jackson.HarmonysoftJacksonConfiguration.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of harmonysoft-jackson Show documentation
Show all versions of harmonysoft-jackson Show documentation
Common general-purpose Kotlin utility
package tech.harmonysoft.oss.jackson
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
import com.fasterxml.jackson.module.kotlin.KotlinModule
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import java.util.*
@Configuration
open class HarmonysoftJacksonConfiguration {
@Json
@Bean
open fun jsonObjectMapper(extensions: Optional>): ObjectMapper {
return ObjectMapper().apply {
configure(this, extensions.orElse(emptyList()))
}
}
private fun configure(mapper: ObjectMapper, extensions: Collection) {
mapper.registerModules(KotlinModule.Builder().build(), KClassModule, JavaTimeModule())
for (extension in extensions) {
extension.configure(mapper)
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy