Example usage for org.springframework.http.converter.json Jackson2ObjectMapperFactoryBean setFeaturesToEnable

List of usage examples for org.springframework.http.converter.json Jackson2ObjectMapperFactoryBean setFeaturesToEnable

Introduction

In this page you can find the example usage for org.springframework.http.converter.json Jackson2ObjectMapperFactoryBean setFeaturesToEnable.

Prototype

public void setFeaturesToEnable(Object... featuresToEnable) 

Source Link

Document

Specify features to enable.

Usage

From source file:org.spring.data.gemfire.rest.GemFireRestInterfaceTest.java

protected ObjectMapper getObjectMapper() {
    if (objectMapper == null) {
        Jackson2ObjectMapperFactoryBean objectMapperFactoryBean = new Jackson2ObjectMapperFactoryBean();

        objectMapperFactoryBean.setFailOnEmptyBeans(true);
        objectMapperFactoryBean.setFeaturesToEnable(Feature.ALLOW_COMMENTS);
        objectMapperFactoryBean.setFeaturesToEnable(Feature.ALLOW_SINGLE_QUOTES);
        objectMapperFactoryBean.setFeaturesToEnable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT);
        objectMapperFactoryBean.setFeaturesToDisable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
        objectMapperFactoryBean.setIndentOutput(true);
        objectMapperFactoryBean.setSimpleDateFormat("MM/dd/yyyy");
        objectMapperFactoryBean.afterPropertiesSet();

        objectMapper = objectMapperFactoryBean.getObject();
    }//from w  w w . ja v a  2s .c om

    return objectMapper;
}