List of usage examples for com.fasterxml.jackson.databind ObjectMapper setAnnotationIntrospector
public ObjectMapper setAnnotationIntrospector(AnnotationIntrospector ai)
From source file:org.jongo.marshall.jackson.configuration.AnnotationModifier.java
public void modify(ObjectMapper mapper) { AnnotationIntrospector jongoIntrospector = new JongoAnnotationIntrospector(); AnnotationIntrospector defaultIntrospector = mapper.getSerializationConfig().getAnnotationIntrospector(); AnnotationIntrospector pair = new AnnotationIntrospectorPair(jongoIntrospector, defaultIntrospector); mapper.setAnnotationIntrospector(pair); }
From source file:com.dell.asm.asmcore.asmmanager.client.util.ServiceTemplateClientUtil.java
private static ObjectMapper buildObjectMapper() { ObjectMapper mapper = new ObjectMapper(); AnnotationIntrospector ai = new JaxbAnnotationIntrospector(mapper.getTypeFactory()); mapper.setAnnotationIntrospector(ai); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); return mapper; }
From source file:org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.java
private void applyConfigurationPropertiesFilter(ObjectMapper mapper) { mapper.setAnnotationIntrospector(new ConfigurationPropertiesAnnotationIntrospector()); mapper.setFilterProvider(//from w ww. j a v a 2s .co m new SimpleFilterProvider().setDefaultFilter(new ConfigurationPropertiesPropertyFilter())); }
From source file:org.springframework.boot.actuate.endpoint.ConfigurationPropertiesReportEndpoint.java
/** * Configure PropertyFilter to make sure Jackson doesn't process CGLIB generated bean * properties.//from ww w. j a v a 2 s . c om */ private void applyCglibFilters(ObjectMapper mapper) { mapper.setAnnotationIntrospector(new CglibAnnotationIntrospector()); mapper.setFilters(new SimpleFilterProvider().addFilter(CGLIB_FILTER_ID, new CglibBeanPropertyFilter())); }
From source file:gt.dakaik.config.WebContext.java
public MappingJackson2HttpMessageConverter jacksonXmlMessageConverter() { MappingJackson2HttpMessageConverter messageConverter = new MappingJackson2HttpMessageConverter(); ObjectMapper mapper = new XmlMapper(); //Registering Hibernate4Module to support lazy objects Hibernate4Module module = new Hibernate4Module(); module.disable(Hibernate4Module.Feature.USE_TRANSIENT_ANNOTATION); mapper.registerModule(module);/*from w w w . ja v a 2s. c o m*/ // Cambiar AnnotationIntrospector para usar anotaciones de JAXB AnnotationIntrospector introspector = new JaxbAnnotationIntrospector(mapper.getTypeFactory()); mapper.setAnnotationIntrospector(introspector); List<MediaType> MediaTypes = new ArrayList<>(); MediaTypes.add(MediaType.APPLICATION_XML); messageConverter.setSupportedMediaTypes(MediaTypes); messageConverter.setObjectMapper(mapper); //log.debug("Listado de MediaTypes: [{}]", messageConverter.getSupportedMediaTypes().toString()); return messageConverter; }
From source file:com.dell.asm.asmcore.asmmanager.util.ServiceTemplateUtil.java
private static ObjectMapper buildBackendObjectMapper() { ObjectMapper mapper = new ObjectMapper(); AnnotationIntrospector ai = new JaxbAnnotationIntrospector(mapper.getTypeFactory()); mapper.setAnnotationIntrospector(ai); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); return mapper; }
From source file:org.springframework.http.converter.json.Jackson2ObjectMapperBuilder.java
/** * Configure an existing {@link ObjectMapper} instance with this builder's * settings. This can be applied to any number of {@code ObjectMappers}. * @param objectMapper the ObjectMapper to configure *///from w ww . j a v a 2 s . c o m public void configure(ObjectMapper objectMapper) { Assert.notNull(objectMapper, "ObjectMapper must not be null"); if (this.findModulesViaServiceLoader) { // Jackson 2.2+ objectMapper.registerModules(ObjectMapper.findModules(this.moduleClassLoader)); } else if (this.findWellKnownModules) { registerWellKnownModulesIfAvailable(objectMapper); } if (this.modules != null) { for (Module module : this.modules) { // Using Jackson 2.0+ registerModule method, not Jackson 2.2+ registerModules objectMapper.registerModule(module); } } if (this.moduleClasses != null) { for (Class<? extends Module> module : this.moduleClasses) { objectMapper.registerModule(BeanUtils.instantiateClass(module)); } } if (this.dateFormat != null) { objectMapper.setDateFormat(this.dateFormat); } if (this.locale != null) { objectMapper.setLocale(this.locale); } if (this.timeZone != null) { objectMapper.setTimeZone(this.timeZone); } if (this.annotationIntrospector != null) { objectMapper.setAnnotationIntrospector(this.annotationIntrospector); } if (this.propertyNamingStrategy != null) { objectMapper.setPropertyNamingStrategy(this.propertyNamingStrategy); } if (this.defaultTyping != null) { objectMapper.setDefaultTyping(this.defaultTyping); } if (this.serializationInclusion != null) { objectMapper.setSerializationInclusion(this.serializationInclusion); } if (this.filters != null) { objectMapper.setFilterProvider(this.filters); } for (Class<?> target : this.mixIns.keySet()) { objectMapper.addMixIn(target, this.mixIns.get(target)); } if (!this.serializers.isEmpty() || !this.deserializers.isEmpty()) { SimpleModule module = new SimpleModule(); addSerializers(module); addDeserializers(module); objectMapper.registerModule(module); } customizeDefaultFeatures(objectMapper); for (Object feature : this.features.keySet()) { configureFeature(objectMapper, feature, this.features.get(feature)); } if (this.handlerInstantiator != null) { objectMapper.setHandlerInstantiator(this.handlerInstantiator); } else if (this.applicationContext != null) { objectMapper.setHandlerInstantiator( new SpringHandlerInstantiator(this.applicationContext.getAutowireCapableBeanFactory())); } }
From source file:org.openecomp.sdnc.sli.aai.AAIService.java
public static ObjectMapper getObjectMapper() { ObjectMapper mapper = new ObjectMapper(); AnnotationIntrospector introspector = new JaxbAnnotationIntrospector(TypeFactory.defaultInstance()); AnnotationIntrospector secondary = new JacksonAnnotationIntrospector(); mapper.setAnnotationIntrospector(AnnotationIntrospector.pair(introspector, secondary)); mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); mapper.setSerializationInclusion(Include.NON_NULL); return mapper; }
From source file:com.dell.asm.asmcore.asmmanager.app.rest.DeploymentService.java
static ObjectMapper buildObjectMapper() { ObjectMapper mapper = new ObjectMapper(); AnnotationIntrospector ai = new JaxbAnnotationIntrospector(mapper.getTypeFactory()); mapper.setAnnotationIntrospector(ai); return mapper; }
From source file:com.dell.asm.asmcore.asmmanager.app.rest.ServiceTemplateService.java
static ObjectMapper buildObjectMapper() { ObjectMapper mapper = new ObjectMapper(); AnnotationIntrospector ai = new JaxbAnnotationIntrospector(mapper.getTypeFactory()); mapper.setAnnotationIntrospector(ai); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); return mapper; }