All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.tairitsu.ignotus.support.service.DefaultJSONMapperProvider.kt Maven / Gradle / Ivy

package com.tairitsu.ignotus.support.service

import com.fasterxml.jackson.databind.DeserializationFeature
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.json.JsonMapper
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
import com.fasterxml.jackson.module.kotlin.KotlinModule
import com.fasterxml.jackson.module.paramnames.ParameterNamesModule
import com.tairitsu.ignotus.support.config.JacksonNamingStrategyConfig

class DefaultJSONMapperProvider() : JSONMapperProvider {

    @Suppress("UNUSED_PARAMETER")
    constructor(jacksonNamingStrategyConfig: JacksonNamingStrategyConfig) : this() {
        objectMapper.propertyNamingStrategy = JacksonNamingStrategyConfig.namingStrategy
    }

    override val objectMapper: ObjectMapper = JsonMapper.builder()
        .addModule(ParameterNamesModule())
        .addModule(Jdk8Module())
        .addModule(JavaTimeModule())
        .addModule(KotlinModule.Builder().build())
        .build()

    init {
        objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy