Example usage for com.fasterxml.jackson.databind.module SimpleModule SimpleModule

List of usage examples for com.fasterxml.jackson.databind.module SimpleModule SimpleModule

Introduction

In this page you can find the example usage for com.fasterxml.jackson.databind.module SimpleModule SimpleModule.

Prototype

public SimpleModule() 

Source Link

Document

Constructors that should only be used for non-reusable convenience modules used by app code: "real" modules should use actual name and version number information.

Usage

From source file:net.turnbig.jdbcx.utilities.JsonMapper.java

public JsonMapper(Include include) {
    mapper = new ObjectMapper();
    // ?// w  w w. j av  a2  s.  c o  m
    if (include != null) {
        mapper.setSerializationInclusion(include);
    }

    SimpleModule module = new SimpleModule();
    module.addDeserializer(Date.class, new Jackson2DateDeserializer());
    mapper.registerModule(module);

    mapper.enable(SerializationFeature.INDENT_OUTPUT);
    // mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));

    // JSONJava
    mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
}

From source file:com.heisenberg.impl.json.JacksonJsonService.java

public JacksonJsonService(ServiceRegistry serviceRegistry) {
    this.objectMapper = serviceRegistry.getService(ObjectMapper.class);
    this.jsonFactory = serviceRegistry.getService(JsonFactory.class);

    objectMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS)
            .setVisibility(PropertyAccessor.ALL, Visibility.NONE)
            .setVisibility(PropertyAccessor.FIELD, Visibility.ANY).setSerializationInclusion(Include.NON_EMPTY);

    SimpleModule module = new SimpleModule();
    module.addSerializer(new LocalDateTimeSerializer());
    module.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer());
    objectMapper.registerModule(module);
}

From source file:org.moserp.common.json_schema.ObjectMapperBuilder.java

private void registerQuantitySerializer(ObjectMapper mapper) {
    SimpleModule module = new SimpleModule();
    module.addSerializer(Quantity.class, new BigDecimalWrapperSerializer());
    module.addSerializer(Price.class, new BigDecimalWrapperSerializer());
    mapper.registerModule(module);/* w w w . jav  a 2  s .com*/
}

From source file:com.hp.autonomy.searchcomponents.hod.search.fields.HodSearchResultDeserializerTest.java

@Before
public void setUp() {
    objectMapper = new ObjectMapper();
    final SimpleModule customModule = new SimpleModule();
    customModule.addDeserializer(HodSearchResult.class, new HodSearchResultDeserializer(configService));
    objectMapper.registerModule(customModule);
    objectMapper.registerModule(new JodaModule());

    final FieldsInfo fieldsInfo = new FieldsInfo.Builder()
            .populateResponseMap("modifiedDate",
                    new FieldInfo<DateTime>("modifiedDate", Arrays.asList("modified_date", "date_modified"),
                            FieldType.DATE))
            .populateResponseMap("links",
                    new FieldInfo<String>("links", Collections.singletonList("links"), FieldType.STRING))
            .build();/* w ww . j a  va2 s.  c o  m*/
    when(config.getFieldsInfo()).thenReturn(fieldsInfo);
    when(configService.getConfig()).thenReturn(config);
}

From source file:com.google.gplus.GooglePlusCommentSerDeTest.java

@Before
public void setup() {
    objectMapper = StreamsJacksonMapper.getInstance();
    SimpleModule simpleModule = new SimpleModule();
    simpleModule.addDeserializer(Comment.class, new GPlusCommentDeserializer());
    objectMapper.registerModule(simpleModule);
    objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

    googlePlusActivityUtil = new GooglePlusActivityUtil();
}

From source file:reactor.js.core.json.NashornJacksonJsonPathProvider.java

public NashornJacksonJsonPathProvider() {
    mapper = new ObjectMapper();
    mapper.configure(SerializationFeature.INDENT_OUTPUT, true);
    mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

    SimpleModule mod = new SimpleModule();
    mod.addSerializer(JSObject.class, new JSObjectSerializer());
    mod.addDeserializer(JSObject.class, new JSObjectDeserializer());
    mapper.registerModule(mod);/*  w ww  . j a  va2 s .  co m*/
}

From source file:com.strategicgains.restexpress.serialization.json.DefaultJsonProcessor.java

public DefaultJsonProcessor() {
    super();
    SimpleModule module = new SimpleModule();
    initializeModule(module);
}

From source file:es.logongas.ix3.web.json.impl.JsonWriterImplEntityJackson.java

public JsonWriterImplEntityJackson() {
    objectMapper = new ObjectMapper();
    SimpleModule module = new SimpleModule();
    module.addSerializer(java.util.Date.class, new DateSerializer());
    objectMapper.registerModule(module);
}

From source file:com.google.gplus.processor.GooglePlusTypeConverterTest.java

@Before
public void setup() {
    objectMapper = StreamsJacksonMapper.getInstance();
    SimpleModule simpleModule = new SimpleModule();
    simpleModule.addDeserializer(Person.class, new GPlusPersonDeserializer());
    simpleModule.addDeserializer(com.google.api.services.plus.model.Activity.class,
            new GPlusActivityDeserializer());
    objectMapper.registerModule(simpleModule);
    objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

    googlePlusTypeConverter = new GooglePlusTypeConverter();
    googlePlusTypeConverter.prepare(null);
}

From source file:org.apache.streams.gplus.GooglePlusCommentSerDeIT.java

/**
 * setup./*from  w  ww .  ja  v  a 2 s. co  m*/
 */
@BeforeClass
public void setupTestCommentObjects() {
    objectMapper = StreamsJacksonMapper.getInstance();
    SimpleModule simpleModule = new SimpleModule();
    simpleModule.addDeserializer(Comment.class, new GPlusCommentDeserializer());
    objectMapper.registerModule(simpleModule);
    objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}