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

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

Introduction

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

Prototype

public void setIndentOutput(boolean indentOutput) 

Source Link

Document

Shortcut for SerializationFeature#INDENT_OUTPUT option.

Usage

From source file:io.getlime.push.configuration.WebApplicationConfig.java

/**
 * Custom object mapper to make sure that dates and other values serialize
 * correctly./*from w  w w .  j a va 2s  .c  om*/
 *
 * @return A new object mapper.
 */
private ObjectMapper objectMapper() {
    Jackson2ObjectMapperFactoryBean bean = new Jackson2ObjectMapperFactoryBean();
    bean.setIndentOutput(true);
    bean.setDateFormat(new ISO8601DateFormat());
    bean.afterPropertiesSet();
    ObjectMapper objectMapper = bean.getObject();
    objectMapper.registerModule(new JodaModule());
    return objectMapper;
}

From source file:com.goodhuddle.huddle.HuddleWebConfig.java

private ObjectMapper objectMapper() {

    Jackson2ObjectMapperFactoryBean bean = new Jackson2ObjectMapperFactoryBean();

    bean.setIndentOutput(true);
    bean.setSimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
    bean.afterPropertiesSet();//from  ww  w  . j  av  a2s  . c  o m

    ObjectMapper objectMapper = bean.getObject();
    objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
    objectMapper.registerModule(new JodaModule());

    return objectMapper;
}

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 ww w . j  a va2 s. co m*/

    return objectMapper;
}