Example usage for com.fasterxml.jackson.databind ObjectMapper setSerializerFactory

List of usage examples for com.fasterxml.jackson.databind ObjectMapper setSerializerFactory

Introduction

In this page you can find the example usage for com.fasterxml.jackson.databind ObjectMapper setSerializerFactory.

Prototype

public ObjectMapper setSerializerFactory(SerializerFactory f) 

Source Link

Document

Method for setting specific SerializerFactory to use for constructing (bean) serializers.

Usage

From source file:org.springframework.amqp.support.converter.Jackson2JsonMessageConverterTests.java

@Test
public void simpleTradeOverrideMapper() {
    ObjectMapper mapper = new ObjectMapper();
    mapper.setSerializerFactory(BeanSerializerFactory.instance);
    converter.setJsonObjectMapper(mapper);

    Message message = converter.toMessage(trade, new MessageProperties());

    SimpleTrade marshalledTrade = (SimpleTrade) converter.fromMessage(message);
    assertEquals(trade, marshalledTrade);
}

From source file:org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.java

/**
 * Ensure only bindable and non-cyclic bean properties are reported.
 * @param mapper the object mapper// ww  w.  j av a 2s  .  co m
 */
private void applySerializationModifier(ObjectMapper mapper) {
    SerializerFactory factory = BeanSerializerFactory.instance
            .withSerializerModifier(new GenericSerializerModifier());
    mapper.setSerializerFactory(factory);
}