Search in sources :

Example 1 with JoynrEnumSerializer

use of io.joynr.messaging.serialize.JoynrEnumSerializer in project joynr by bmwcarit.

the class AbstractBounceProxyServerTest method getObjectMapper.

// ///////////////////////
// HELPERS
private ObjectMapper getObjectMapper() {
    objectMapper = new ObjectMapper();
    objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    objectMapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false);
    // objectMapper.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS,
    // true);
    objectMapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, true);
    objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
    objectMapper.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true);
    objectMapper.enableDefaultTypingAsProperty(DefaultTyping.JAVA_LANG_OBJECT, "_typeName");
    TypeResolverBuilder<?> joynrTypeResolverBuilder = objectMapper.getSerializationConfig().getDefaultTyper(SimpleType.construct(Object.class));
    SimpleModule module = new SimpleModule("NonTypedModule", new Version(1, 0, 0, "", "", ""));
    module.addSerializer(new JoynrEnumSerializer());
    module.addSerializer(new JoynrListSerializer());
    TypeDeserializer typeDeserializer = joynrTypeResolverBuilder.buildTypeDeserializer(objectMapper.getDeserializationConfig(), SimpleType.construct(Object.class), null);
    module.addDeserializer(Object.class, new JoynrUntypedObjectDeserializer(typeDeserializer));
    objectMapper.registerModule(module);
    return objectMapper;
}
Also used : JoynrUntypedObjectDeserializer(io.joynr.messaging.serialize.JoynrUntypedObjectDeserializer) Version(com.fasterxml.jackson.core.Version) JoynrListSerializer(io.joynr.messaging.serialize.JoynrListSerializer) JoynrEnumSerializer(io.joynr.messaging.serialize.JoynrEnumSerializer) TypeDeserializer(com.fasterxml.jackson.databind.jsontype.TypeDeserializer) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) SimpleModule(com.fasterxml.jackson.databind.module.SimpleModule)

Aggregations

Version (com.fasterxml.jackson.core.Version)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 TypeDeserializer (com.fasterxml.jackson.databind.jsontype.TypeDeserializer)1 SimpleModule (com.fasterxml.jackson.databind.module.SimpleModule)1 JoynrEnumSerializer (io.joynr.messaging.serialize.JoynrEnumSerializer)1 JoynrListSerializer (io.joynr.messaging.serialize.JoynrListSerializer)1 JoynrUntypedObjectDeserializer (io.joynr.messaging.serialize.JoynrUntypedObjectDeserializer)1