use of com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector in project build-info by JFrogDev.
the class BuildInfoExtractorUtils method createJsonFactory.
// TODO: [by YS] duplicates ArtifactoryBuildInfoClient. The client should depend on this module
// TODO: [by yl] introduce a commons module for common impl and also move PropertyUtils there
private static JsonFactory createJsonFactory() {
JsonFactory jsonFactory = new JsonFactory();
ObjectMapper mapper = new ObjectMapper(jsonFactory);
mapper.setAnnotationIntrospector(new JacksonAnnotationIntrospector());
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
jsonFactory.setCodec(mapper);
return jsonFactory;
}
use of com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector in project oxAuth by GluuFederation.
the class ServerUtil method createJsonMapper.
public static ObjectMapper createJsonMapper() {
final AnnotationIntrospector jaxb = new JaxbAnnotationIntrospector();
final AnnotationIntrospector jackson = new JacksonAnnotationIntrospector();
final AnnotationIntrospector pair = AnnotationIntrospector.pair(jackson, jaxb);
final ObjectMapper mapper = new ObjectMapper();
mapper.getDeserializationConfig().with(pair);
mapper.getSerializationConfig().with(pair);
return mapper;
}
use of com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector in project platformlayer by platformlayer.
the class JsonHelper method buildObjectMapper.
public static ObjectMapper buildObjectMapper(TypeFactory typeFactory, boolean formatted) {
ObjectMapper mapper = new ObjectMapper();
if (typeFactory == null) {
typeFactory = TypeFactory.defaultInstance();
}
if (formatted) {
mapper.enable(SerializationFeature.INDENT_OUTPUT);
}
// Favor JAXB annotations
AnnotationIntrospector jaxbIntrospector = new JaxbAnnotationIntrospector(typeFactory);
AnnotationIntrospector jacksonIntrospector = new JacksonAnnotationIntrospector();
AnnotationIntrospector introspector = new AnnotationIntrospectorPair(jaxbIntrospector, jacksonIntrospector);
mapper.setAnnotationIntrospector(introspector);
return mapper;
}
use of com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector in project zm-mailbox by Zimbra.
the class JaxbToJsonTest method getSimpleJsonJaxbMapper.
public ObjectMapper getSimpleJsonJaxbMapper() {
ObjectMapper mapper = new ObjectMapper();
mapper.setAnnotationIntrospector(AnnotationIntrospector.pair(new JacksonAnnotationIntrospector(), new JaxbAnnotationIntrospector()));
mapper.enable(SerializationFeature.INDENT_OUTPUT);
return mapper;
}
use of com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector in project oap by oaplatform.
the class Binder method initialize.
private static ObjectMapper initialize(ObjectMapper mapper, boolean defaultTyping, boolean nonNullInclusion, boolean skipInputNulls) {
if (mapper instanceof XmlMapper) {
((XmlMapper) mapper).setDefaultUseWrapper(false);
((XmlMapper) mapper).configure(ToXmlGenerator.Feature.WRITE_XML_DECLARATION, true);
}
AnnotationIntrospector introspector = new JacksonAnnotationIntrospector();
mapper.getDeserializationConfig().with(introspector);
mapper.getSerializationConfig().with(introspector);
mapper.registerModule(new AfterburnerModule());
mapper.registerModule(new Jdk8Module().configureAbsentsAsNulls(true));
mapper.registerModule(new JodaModule());
mapper.registerModule(new ExtModule());
mapper.registerModule(new JavaTimeModule());
mapper.registerModule(new ParameterNamesModule(JsonCreator.Mode.DEFAULT));
mapper.enable(DeserializationFeature.USE_LONG_FOR_INTS);
mapper.enable(JsonParser.Feature.ALLOW_SINGLE_QUOTES);
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
mapper.disable(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS);
mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
mapper.configure(JsonGenerator.Feature.AUTO_CLOSE_TARGET, false);
mapper.enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES);
mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
// todo remove after kernel cleanup
mapper.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
if (skipInputNulls)
mapper.setDefaultSetterInfo(JsonSetter.Value.forValueNulls(Nulls.SKIP));
if (!nonNullInclusion)
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
modules.forEach(mapper::registerModule);
if (defaultTyping)
mapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
return mapper;
}
Aggregations