use of oap.json.ext.ExtModule 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