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

Source Link

Document

Convenience constructor that will use specified Version, including name from Version#getArtifactId()

Usage

From source file:com.metamx.cache.CaffeineDruidModule.java

@Override
public List<? extends Module> getJacksonModules() {
    return ImmutableList.of(new SimpleModule("DruidCaffeineCache-" + System.identityHashCode(this))
            .registerSubtypes(CaffeineCacheProvider.class));
}

From source file:com.tilab.fiware.metaware.dao.impls.mongodb.core.CustomObjectMapper.java

/**
 * Custom ObjectMapper definition./*from   w  w w .  j  av  a  2  s.  c  o  m*/
 */
public CustomObjectMapper() {
    SimpleModule module = new SimpleModule("ObjectIdmodule");
    module.addSerializer(ObjectId.class, new ObjectIdSerializer()); // specify the custom ObjectId serializer
    this.registerModule(module);
}

From source file:com.kixeye.chassis.transport.swagger.SwaggerRegistry.java

private static Module swaggerSerializationModule() {
    SimpleModule module = new SimpleModule("SwaggerJacksonModule");
    module.addSerializer(ApiListing.class, new SwaggerApiListingJsonSerializer());
    module.addSerializer(ResourceListing.class, new SwaggerResourceListingJsonSerializer());
    return module;
}

From source file:com.setronica.ucs.storage.JSONTest.java

public void testParse() throws IOException {

    ObjectMapper mapper = new ObjectMapper();
    SimpleModule enumModule = new SimpleModule("EnumModule").addDeserializer(ProductIdentity.class,
            new PgStructMapStorage.MemProductIdentityDeserializer(new ProductIdentityFactory()));
    mapper.registerModule(enumModule);//from   w w w . j a  va  2  s .co m
    MemPackedProduct p = new MemPackedProduct();
    p.setLastModified(1);
    p.setIdentities(new ProductIdentity[] { new AsinIdentity("B005Y3721U"), new EanIdentity("234") });
    p.setContents(new HashMap<String, MemPackedProductContent>());
    p.getContents().put("bob", new MemPackedProductContent());
    String json = mapper.writeValueAsString(p);
    MemPackedProduct p2 = mapper.readValue(json, MemPackedProduct.class);
    assertEquals(p.getLastModified(), p2.getLastModified());
    assertEquals(p.getIdentities().length, p2.getIdentities().length);
    assertEquals(p.getIdentities()[0], p2.getIdentities()[0]);
    assertEquals(p.getIdentities()[1], p2.getIdentities()[1]);
}

From source file:org.openmhealth.schema.serializer.Rfc3339OffsetDateTimeSerializerUnitTests.java

@BeforeClass
public void initializeObjectMapper() throws IOException {

    objectMapper = new ObjectMapper();

    SimpleModule rfc3339Module = new SimpleModule("rfc3339Module");
    rfc3339Module.addSerializer(new Rfc3339OffsetDateTimeSerializer(OffsetDateTime.class));
    objectMapper.registerModule(rfc3339Module);
}

From source file:io.druid.extension.lucene.LuceneDruidModule.java

@Override
public List<? extends Module> getJacksonModules() {
    return ImmutableList.of(new SimpleModule(LuceneDruidModule.class.getSimpleName()).registerSubtypes(
            new NamedType(AppenderatorPlumberSchool.class, "appenderator"),
            new NamedType(LuceneDruidQuery.class, "lucene")));
}

From source file:org.basinmc.maven.plugins.minecraft.access.AccessTransformationMap.java

/**
 * Reads an access transformation map from a supplied path.
 *
 * @throws IOException when accessing the file fails.
 *//* w  w  w  . j av a2 s  . c o  m*/
@Nonnull
public static AccessTransformationMap read(@Nonnull Path path) throws IOException {
    ObjectMapper mapper = new ObjectMapper();

    {
        SimpleModule module = new SimpleModule("Access Transformation Serialization");
        module.addDeserializer(Visibility.class, new VisibilityJsonDeserializer());
        mapper.registerModule(module);
    }

    try (FileInputStream inputStream = new FileInputStream(path.toFile())) {
        return mapper.readValue(inputStream, AccessTransformationMap.class);
    }
}

From source file:org.cryptomator.ui.model.VaultObjectMapperProvider.java

@Override
public ObjectMapper get() {
    final ObjectMapper om = new ObjectMapper();
    final SimpleModule module = new SimpleModule("VaultJsonMapper");
    module.addSerializer(Vault.class, new VaultSerializer());
    module.addDeserializer(Vault.class, new VaultDeserializer());
    om.registerModule(module);//from w ww.j a v  a  2  s. c o  m
    return om;
}

From source file:com.nebhale.cyclinglibrary.web.json.JsonSerializerRegisteringBeanPostProcessor.java

@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
    if (bean instanceof JsonSerializer) {
        JsonSerializer<?> jsonSerializer = (JsonSerializer<?>) bean;
        this.objectMapper.registerModule(new SimpleModule(beanName).addSerializer(jsonSerializer));
    }//  w  w w.j av  a2s. c o m

    return bean;
}

From source file:com.google.code.pathlet.web.json.JsonRequestProcessor.java

public JsonRequestProcessor(Map<String, String> parameterPropertyMap,
        Map<Class<?>, JsonDeserializer<?>> deserializerMap) {
    this.objectMapper = new ObjectMapper();

    SimpleModule testModule = new SimpleModule("MyModule");

    if (deserializerMap != null && deserializerMap.size() > 0) {
        for (Map.Entry<Class<?>, JsonDeserializer<?>> entry : deserializerMap.entrySet()) {
            Class type = entry.getKey();
            JsonDeserializer serializer = entry.getValue();
            testModule.addDeserializer(type, serializer);
        }/*from w  w  w .j a  va2 s  .c  om*/
        objectMapper.registerModule(testModule);
    }

    this.parameterPropertyMap = parameterPropertyMap;
}