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

org.nofdev.topic.ObjectMapperFactory.groovy Maven / Gradle / Ivy

There is a newer version: 1.7.6
Show newest version
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
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy