com.fasterxml.jackson.databind.deser.BeanDeserializerFactory Java Examples
The following examples show how to use
com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ObjectMapperProvider.java From icure-backend with GNU General Public License v2.0 | 6 votes |
@Override public ObjectMapper getContext(Class<?> type) { // TypeResolver SimpleAbstractTypeResolver abstractTypeResolver = new SimpleAbstractTypeResolver(); abstractTypeResolver.addMapping(List.class, ArrayList.class); abstractTypeResolver.addMapping(Set.class, HashSet.class); abstractTypeResolver.addMapping(Map.class, HashMap.class); // Serializer DefaultSerializerProvider serializerProvider = new DefaultSerializerProvider.Impl(); // Deserializer DeserializerFactoryConfig deserializerFactoryConfig = new DeserializerFactoryConfig().withAbstractTypeResolver(abstractTypeResolver); BeanDeserializerFactory deserializerFactory = new BeanDeserializerFactory(deserializerFactoryConfig); DefaultDeserializationContext.Impl deserializationContext = new DefaultDeserializationContext.Impl(deserializerFactory); // ObjectMapper ObjectMapper objectMapper = new ObjectMapper(null, serializerProvider, deserializationContext); objectMapper = objectMapper.enableDefaultTypingAsProperty(ObjectMapper.DefaultTyping.OBJECT_AND_NON_CONCRETE, "type"); objectMapper = objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); objectMapper = objectMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS); return objectMapper; }
Example #2
Source File: AWSUtil.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * Set all prefixed properties on {@link ClientConfiguration}. * @param config * @param configProps */ public static void setAwsClientConfigProperties(ClientConfiguration config, Properties configProps) { Map<String, Object> awsConfigProperties = new HashMap<>(); for (Map.Entry<Object, Object> entry : configProps.entrySet()) { String key = (String) entry.getKey(); if (key.startsWith(AWS_CLIENT_CONFIG_PREFIX)) { awsConfigProperties.put(key.substring(AWS_CLIENT_CONFIG_PREFIX.length()), entry.getValue()); } } // Jackson does not like the following properties String[] ignorableProperties = {"secureRandom"}; BeanDeserializerModifier modifier = new BeanDeserializerModifierForIgnorables( ClientConfiguration.class, ignorableProperties); DeserializerFactory factory = BeanDeserializerFactory.instance.withDeserializerModifier( modifier); ObjectMapper mapper = new ObjectMapper(null, null, new DefaultDeserializationContext.Impl(factory)); JsonNode propTree = mapper.convertValue(awsConfigProperties, JsonNode.class); try { mapper.readerForUpdating(config).readValue(propTree); } catch (IOException ex) { throw new RuntimeException(ex); } }
Example #3
Source File: AWSUtil.java From flink with Apache License 2.0 | 5 votes |
/** * Set all prefixed properties on {@link ClientConfiguration}. * @param config * @param configProps */ public static void setAwsClientConfigProperties(ClientConfiguration config, Properties configProps) { Map<String, Object> awsConfigProperties = new HashMap<>(); for (Map.Entry<Object, Object> entry : configProps.entrySet()) { String key = (String) entry.getKey(); if (key.startsWith(AWS_CLIENT_CONFIG_PREFIX)) { awsConfigProperties.put(key.substring(AWS_CLIENT_CONFIG_PREFIX.length()), entry.getValue()); } } // Jackson does not like the following properties String[] ignorableProperties = {"secureRandom"}; BeanDeserializerModifier modifier = new BeanDeserializerModifierForIgnorables( ClientConfiguration.class, ignorableProperties); DeserializerFactory factory = BeanDeserializerFactory.instance.withDeserializerModifier( modifier); ObjectMapper mapper = new ObjectMapper(null, null, new DefaultDeserializationContext.Impl(factory)); JsonNode propTree = mapper.convertValue(awsConfigProperties, JsonNode.class); try { mapper.readerForUpdating(config).readValue(propTree); } catch (IOException ex) { throw new RuntimeException(ex); } }
Example #4
Source File: AWSUtil.java From flink with Apache License 2.0 | 5 votes |
/** * Set all prefixed properties on {@link ClientConfiguration}. * @param config * @param configProps */ public static void setAwsClientConfigProperties(ClientConfiguration config, Properties configProps) { Map<String, Object> awsConfigProperties = new HashMap<>(); for (Map.Entry<Object, Object> entry : configProps.entrySet()) { String key = (String) entry.getKey(); if (key.startsWith(AWS_CLIENT_CONFIG_PREFIX)) { awsConfigProperties.put(key.substring(AWS_CLIENT_CONFIG_PREFIX.length()), entry.getValue()); } } // Jackson does not like the following properties String[] ignorableProperties = {"secureRandom"}; BeanDeserializerModifier modifier = new BeanDeserializerModifierForIgnorables( ClientConfiguration.class, ignorableProperties); DeserializerFactory factory = BeanDeserializerFactory.instance.withDeserializerModifier( modifier); ObjectMapper mapper = new ObjectMapper(null, null, new DefaultDeserializationContext.Impl(factory)); JsonNode propTree = mapper.convertValue(awsConfigProperties, JsonNode.class); try { mapper.readerForUpdating(config).readValue(propTree); } catch (IOException ex) { throw new RuntimeException(ex); } }