org.nofdev.topic.ObjectMapperFactory.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of service-topic-consumer Show documentation
Show all versions of service-topic-consumer Show documentation
The basic componet of Nofdev Topic framework
package org.nofdev.topic
import com.fasterxml.jackson.databind.DeserializationFeature
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.SerializationFeature
import com.fasterxml.jackson.datatype.joda.JodaModule
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
import groovy.transform.CompileStatic
/**
* Created by Liutengfei on 2016/5/6 0006.
*/
@CompileStatic
class ObjectMapperFactory {
static ObjectMapper createObjectMapper() {
ObjectMapper objectMapper = new ObjectMapper()
objectMapper.registerModule(new JodaModule())
objectMapper.registerModule(new JavaTimeModule())
objectMapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true)
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS,false)
return objectMapper
}
}