use of com.fasterxml.jackson.databind.DeserializationConfig in project autorest-clientruntime-for-java by Azure.
the class FlatteningDeserializer method getModule.
/**
* Gets a module wrapping this serializer as an adapter for the Jackson
* ObjectMapper.
*
* @param mapper the object mapper for default deserializations
* @return a simple module to be plugged onto Jackson ObjectMapper.
*/
public static SimpleModule getModule(final ObjectMapper mapper) {
SimpleModule module = new SimpleModule();
module.setDeserializerModifier(new BeanDeserializerModifier() {
@Override
public JsonDeserializer<?> modifyDeserializer(DeserializationConfig config, BeanDescription beanDesc, JsonDeserializer<?> deserializer) {
if (beanDesc.getBeanClass().getAnnotation(JsonFlatten.class) != null) {
return new FlatteningDeserializer(beanDesc.getBeanClass(), deserializer, mapper);
}
return deserializer;
}
});
return module;
}
use of com.fasterxml.jackson.databind.DeserializationConfig in project Activiti by Activiti.
the class CommonModelAutoConfiguration method customizeCommonModelObjectMapper.
// this bean will be automatically injected inside boot's ObjectMapper
@Bean
public Module customizeCommonModelObjectMapper() {
SimpleModule module = new SimpleModule("mapCommonModelInterfaces", Version.unknownVersion());
SimpleAbstractTypeResolver resolver = new SimpleAbstractTypeResolver() {
// this is a workaround for https://github.com/FasterXML/jackson-databind/issues/2019
// once version 2.9.6 is related we can remove this @override method
@Override
public JavaType resolveAbstractType(DeserializationConfig config, BeanDescription typeDesc) {
return findTypeMapping(config, typeDesc.getType());
}
};
resolver.addMapping(VariableInstance.class, VariableInstanceImpl.class);
module.setAbstractTypes(resolver);
module.setMixInAnnotation(Payload.class, PayloadMixIn.class);
module.setMixInAnnotation(Result.class, ResultMixIn.class);
module.registerSubtypes(new NamedType(EmptyResult.class, EmptyResult.class.getSimpleName()));
return module;
}
use of com.fasterxml.jackson.databind.DeserializationConfig in project jackson-databind by FasterXML.
the class TestJDKSerialization method testConfigs.
public void testConfigs() throws IOException {
byte[] base = jdkSerialize(MAPPER.getDeserializationConfig().getBaseSettings());
assertNotNull(jdkDeserialize(base));
// first things first: underlying BaseSettings
DeserializationConfig origDC = MAPPER.getDeserializationConfig();
SerializationConfig origSC = MAPPER.getSerializationConfig();
byte[] dcBytes = jdkSerialize(origDC);
byte[] scBytes = jdkSerialize(origSC);
DeserializationConfig dc = jdkDeserialize(dcBytes);
assertNotNull(dc);
assertEquals(dc._deserFeatures, origDC._deserFeatures);
SerializationConfig sc = jdkDeserialize(scBytes);
assertNotNull(sc);
assertEquals(sc._serFeatures, origSC._serFeatures);
}
use of com.fasterxml.jackson.databind.DeserializationConfig in project nakadi by zalando.
the class JsonConfig method enumModule.
private SimpleModule enumModule() {
// see http://stackoverflow.com/questions/24157817/jackson-databind-enum-case-insensitive
final SimpleModule enumModule = new SimpleModule();
enumModule.setDeserializerModifier(new BeanDeserializerModifier() {
@Override
public JsonDeserializer<Enum> modifyEnumDeserializer(final DeserializationConfig config, final JavaType type, final BeanDescription beanDesc, final JsonDeserializer<?> deserializer) {
return new LowerCaseEnumJsonDeserializer(type);
}
});
enumModule.addSerializer(Enum.class, new LowerCaseEnumJsonSerializer());
return enumModule;
}
use of com.fasterxml.jackson.databind.DeserializationConfig in project web3sdk by FISCO-BCOS.
the class ObjectMapperFactory method configureObjectMapper.
private static ObjectMapper configureObjectMapper(ObjectMapper objectMapper, boolean shouldIncludeRawResponses) {
if (shouldIncludeRawResponses) {
SimpleModule module = new SimpleModule();
module.setDeserializerModifier(new BeanDeserializerModifier() {
@Override
public JsonDeserializer<?> modifyDeserializer(DeserializationConfig config, BeanDescription beanDesc, JsonDeserializer<?> deserializer) {
if (Response.class.isAssignableFrom(beanDesc.getBeanClass())) {
return new RawResponseDeserializer(deserializer);
}
return deserializer;
}
});
objectMapper.registerModule(module);
}
objectMapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
return objectMapper;
}
Aggregations