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(String name, Version version) 

Source Link

Document

Constructor to use for actual reusable modules.

Usage

From source file:com.bazaarvoice.jolt.JsonUtilImpl.java

public static void configureStockJoltObjectMapper(ObjectMapper objectMapper) {

    // All Json maps should be deserialized into LinkedHashMaps.
    SimpleModule stockModule = new SimpleModule("stockJoltMapping", new Version(1, 0, 0, null, null, null))
            .addAbstractTypeMapping(Map.class, LinkedHashMap.class);

    objectMapper.registerModule(stockModule);

    // allow the mapper to parse JSON with comments in it
    objectMapper.configure(JsonParser.Feature.ALLOW_COMMENTS, true);
}

From source file:io.hightide.renderers.JacksonJsonRenderer.java

public JacksonJsonRenderer() {
    mapper = new ObjectMapper();
    SimpleModule defaultModule = new SimpleModule("DefaultHightideModule", new Version(1, 0, 0, null));
    //        defaultModule.addSerializer(Record.class, new JooqRecordJsonSerializer());
    mapper.registerModule(defaultModule);
}

From source file:com.basho.riak.client.raw.http.NamedErlangFunctionDeserializerTest.java

/**
 * @throws java.lang.Exception/*  w w  w.j a  va  2s .  com*/
 */
@Before
public void setUp() throws Exception {
    objectMapper = new ObjectMapper();
    objectMapper.registerModule(
            new SimpleModule("test_quorm_deserialzer", new Version(1, 0, 0, "SNAPSHOT", null, null))
                    .addDeserializer(NamedErlangFunction.class, new NamedErlangFunctionDeserializer()));
}

From source file:com.basho.riak.client.raw.http.QuorumDeserializerTest.java

/**
 * @throws java.lang.Exception/*from  w w  w . j  a v a 2 s.  c  o  m*/
 */
@Before
public void setUp() throws Exception {
    objectMapper = new ObjectMapper();
    objectMapper.registerModule(
            new SimpleModule("test_quorm_deserialzer", new Version(1, 0, 0, "SNAPSHOT", null, null))
                    .addDeserializer(Quorum.class, new QuorumDeserializer()));
}

From source file:com.tikinou.schedulesdirect.core.jackson.ModuleRegistration.java

private ModuleRegistration() {
    customModule = new SimpleModule("com.tikinou.schedulesdirect.core.jackson.module",
            new Version(1, 0, 0, null, null, null));
    customModule.addDeserializer(ResponseCode.class,
            new StdDelegatingDeserializer<>(new ResponseCodeConverter()));
    customModule.addDeserializer(GetHeadendsResult.class,
            new StdDelegatingDeserializer<>(new HeadendResultConverter()));
    //        customModule.addDeserializer(GetHeadendsResult.class, new HeadendResultDeserializer());
    //        customModule.addDeserializer(Boolean.class, new BooleanYNDeserializer());
    //        customModule.addDeserializer(Boolean.TYPE, new BooleanYNDeserializer());
}

From source file:be.dnsbelgium.rdap.jackson.CustomObjectMapper.java

public CustomObjectMapper() {
    super.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
    setSerializationInclusion(JsonInclude.Include.NON_NULL);
    configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
    configure(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS, false);
    SimpleModule simpleModule = new SimpleModule("SimpleModule", new Version(1, 0, 0, null));

    simpleModule.addSerializer(new RDAPContactSerializer());
    simpleModule.addSerializer(new StructuredValueSerializer());
    simpleModule.addSerializer(new TextListSerializer());
    simpleModule.addSerializer(new TextSerializer());
    simpleModule.addSerializer(new URIValueSerializer());
    simpleModule.addSerializer(new DomainNameSerializer());
    simpleModule.addSerializer(new DateTimeSerializer());
    simpleModule.addSerializer(new StatusSerializer());
    for (JsonSerializer serializer : getSerializers()) {
        simpleModule.addSerializer(serializer);
    }// w ww.  j  av a 2s  .  c o  m

    registerModule(simpleModule);
}

From source file:com.algodefu.yeti.web.rest.JacksonConfig.java

public JacksonConfig() {
    objectMapper = new ObjectMapper();
    objectMapper.addMixInAnnotations(Pass.class, PassMixin.class);
    SimpleModule module = new SimpleModule("MyModule", new Version(1, 0, 0, null));
    module.addSerializer(ClusterFormat.class, new ClusterFormatSerializer());
    module.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer());
    module.addSerializer(Parameter.class, new ParameterSerializer());
    module.addSerializer(RangeParameter.class, new RangeParameterSerializer());
    objectMapper.registerModule(module);
}

From source file:com.company.et.service.JsonService.java

public static Professor[] jsonToObjectProfessorArray(String json) throws IOException, ParseException {

    ObjectMapper mapper = new ObjectMapper();
    List<String> json_list = split(json);

    Professor[] profs = new Professor[json_list.size()];

    SimpleModule testModule = new SimpleModule("MyModule", new Version(1, 0, 0, null))
            .addDeserializer(Professor.class, new ProfessorDeserializer());

    mapper.registerModule(testModule);/*from  w  w  w  . j a va2  s.  c o  m*/

    for (int i = 0; i < json_list.size(); i++) {
        //System.out.println(json_list.get(i));
        profs[i] = mapper.readValue(json_list.get(i), Professor.class);
    }

    return profs;
}

From source file:jp.classmethod.aws.brian.util.BrianClientObjectMapper.java

/**
 * Instantiate./*  w  w  w .  jav a2s .  com*/
 */
public BrianClientObjectMapper() {
    SimpleModule brianModule = new SimpleModule("brianClientModule", VERSION);
    registerModule(brianModule);
    registerModule(new Jdk8Module());

    configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
    configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
    setVisibility(PropertyAccessor.FIELD, Visibility.ANY);

    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
    df.setTimeZone(TimeZone.getTimeZone("Universal"));
    setDateFormat(df);
}

From source file:com.basho.riak.client.itest.ITestStats.java

@Test
public void testDeserializer() throws IOException {
    NodeStats.UndefinedStatDeserializer usd = new NodeStats.UndefinedStatDeserializer();
    SimpleModule module = new SimpleModule("UndefinedStatDeserializer", new Version(1, 0, 0, null, null, null));
    module.addDeserializer(BigInteger.class, usd);

    String json = "{\"vnode_gets\":\"deprecated\",\"vnode_gets_total\":12345678}";

    ObjectMapper mapper = new ObjectMapper();
    mapper.registerModule(module);/* ww  w. j a v a2s.c o  m*/
    NodeStats stats = mapper.readValue(json, NodeStats.class);
    assertEquals(stats.vnodeGets(), BigInteger.ZERO);
    assertEquals(stats.vnodeGetsTotal(), BigInteger.valueOf(12345678));

}