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

org.nofdev.servicefacade.JsonConfiguration.groovy Maven / Gradle / Ivy

There is a newer version: 1.4.1
Show newest version
package org.nofdev.servicefacade

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 org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration

/**
 * Created by Qiang on 11/6/15.
 */
@Configuration
class JsonConfiguration {

    @Bean
    ObjectMapper objectMapper() {
        ObjectMapper objectMapper = new ObjectMapper()
        objectMapper.registerModule(new JodaModule())
        objectMapper.registerModule(new JavaTimeModule())
//        objectMapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true)副作用较大
        objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
        objectMapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true)
        objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS,false)
        objectMapper
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy