org.nofdev.servicefacade.JsonConfiguration.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of service-host-mvc Show documentation
Show all versions of service-host-mvc Show documentation
The server side componet of Nofdev RPC framework
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
}
}