com.jchanghong.utils.gson.GsonHelper.kt Maven / Gradle / Ivy
The newest version!
package com.jchanghong.utils.gson
import com.fasterxml.jackson.annotation.JsonInclude
import com.fasterxml.jackson.databind.DeserializationFeature
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.SerializationFeature
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
object JsonHelper {
fun newJacksonMapper(): ObjectMapper {
val objectMapper = jacksonObjectMapper()
objectMapper.setSerializationInclusion(JsonInclude.Include.ALWAYS)
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,false)
objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS,false)
return objectMapper
}
}