Search in sources :

Example 1 with SimpleSerializers

use of com.fasterxml.jackson.databind.module.SimpleSerializers in project pinpoint by naver.

the class JacksonPinpointModule method setupModule.

/* (non-Javadoc)
     * @see com.fasterxml.jackson.databind.Module#setupModule(org.codehaus.jackson.map.Module.SetupContext)
     */
@Override
public void setupModule(SetupContext context) {
    SimpleSerializers serializers = new SimpleSerializers();
    serializers.addSerializer(ServiceType.class, new ServiceTypeSerializer());
    context.addSerializers(serializers);
}
Also used : SimpleSerializers(com.fasterxml.jackson.databind.module.SimpleSerializers)

Example 2 with SimpleSerializers

use of com.fasterxml.jackson.databind.module.SimpleSerializers in project sling by apache.

the class ResourceModuleProvider method activate.

@Activate
private void activate(Map<String, Object> props) {
    final int maxRecursionLevels = PropertiesUtil.toInteger(props.get(PROP_MAX_RECURSION_LEVELS), DEFAULT_MAX_RECURSION_LEVELS);
    this.moduleInstance = new SimpleModule();
    SimpleSerializers serializers = new SimpleSerializers();
    serializers.addSerializer(Resource.class, new ResourceSerializer(maxRecursionLevels));
    moduleInstance.setSerializers(serializers);
}
Also used : SimpleSerializers(com.fasterxml.jackson.databind.module.SimpleSerializers) SimpleModule(com.fasterxml.jackson.databind.module.SimpleModule) Activate(org.apache.felix.scr.annotations.Activate)

Example 3 with SimpleSerializers

use of com.fasterxml.jackson.databind.module.SimpleSerializers in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class PageModuleProviderTest method testPageModule.

@Test
public void testPageModule() throws Exception {
    PageModuleProvider pmp = new PageModuleProvider();
    Module module = pmp.getModule();
    assertTrue(module instanceof SimpleModule);
    Field field = module.getClass().getDeclaredField("_serializers");
    field.setAccessible(true);
    SimpleSerializers simpleSerializers = (SimpleSerializers) field.get(module);
    field = simpleSerializers.getClass().getDeclaredField("_interfaceMappings");
    field.setAccessible(true);
    HashMap<ClassKey, JsonSerializer<?>> classMappings = (HashMap) field.get(simpleSerializers);
    assertTrue(classMappings.containsKey(new ClassKey(Page.class)));
}
Also used : Field(java.lang.reflect.Field) HashMap(java.util.HashMap) ClassKey(com.fasterxml.jackson.databind.type.ClassKey) SimpleSerializers(com.fasterxml.jackson.databind.module.SimpleSerializers) JsonSerializer(com.fasterxml.jackson.databind.JsonSerializer) Module(com.fasterxml.jackson.databind.Module) SimpleModule(com.fasterxml.jackson.databind.module.SimpleModule) SimpleModule(com.fasterxml.jackson.databind.module.SimpleModule) Test(org.junit.jupiter.api.Test)

Example 4 with SimpleSerializers

use of com.fasterxml.jackson.databind.module.SimpleSerializers in project hive by apache.

the class MapCapableJsonMetricsModule method setupModule.

public void setupModule(SetupContext context) {
    super.setupModule(context);
    context.addSerializers(new SimpleSerializers(ImmutableList.of(new MetricRegistrySerializer(version(), MetricFilter.ALL), new MapMetricsBeanSerializer())));
}
Also used : SimpleSerializers(com.fasterxml.jackson.databind.module.SimpleSerializers)

Example 5 with SimpleSerializers

use of com.fasterxml.jackson.databind.module.SimpleSerializers in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class PageModuleProviderTest method testPageModule.

@Test
public void testPageModule() throws Exception {
    PageModuleProvider pmp = new PageModuleProvider();
    Module module = pmp.getModule();
    assertTrue(module instanceof SimpleModule);
    Field field = module.getClass().getDeclaredField("_serializers");
    field.setAccessible(true);
    SimpleSerializers simpleSerializers = (SimpleSerializers) field.get(module);
    field = simpleSerializers.getClass().getDeclaredField("_interfaceMappings");
    field.setAccessible(true);
    HashMap<ClassKey, JsonSerializer<?>> classMappings = (HashMap) field.get(simpleSerializers);
    assertTrue(classMappings.containsKey(new ClassKey(Page.class)));
}
Also used : Field(java.lang.reflect.Field) HashMap(java.util.HashMap) ClassKey(com.fasterxml.jackson.databind.type.ClassKey) SimpleSerializers(com.fasterxml.jackson.databind.module.SimpleSerializers) JsonSerializer(com.fasterxml.jackson.databind.JsonSerializer) Module(com.fasterxml.jackson.databind.Module) SimpleModule(com.fasterxml.jackson.databind.module.SimpleModule) SimpleModule(com.fasterxml.jackson.databind.module.SimpleModule) Test(org.junit.Test)

Aggregations

SimpleSerializers (com.fasterxml.jackson.databind.module.SimpleSerializers)6 SimpleModule (com.fasterxml.jackson.databind.module.SimpleModule)4 JsonSerializer (com.fasterxml.jackson.databind.JsonSerializer)2 Module (com.fasterxml.jackson.databind.Module)2 ClassKey (com.fasterxml.jackson.databind.type.ClassKey)2 Field (java.lang.reflect.Field)2 HashMap (java.util.HashMap)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Activate (org.apache.felix.scr.annotations.Activate)1 Test (org.junit.Test)1 Test (org.junit.jupiter.api.Test)1