in aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/factories/JacksonFactory.java [52:117]
private static ObjectMapper createObjectMapper() {
ObjectMapper mapper = new ObjectMapper(createJsonFactory());
SerializationConfig scfg = mapper.getSerializationConfig();
scfg = scfg.withFeatures(
SerializationFeature.FAIL_ON_SELF_REFERENCES,
SerializationFeature.FAIL_ON_UNWRAPPED_TYPE_IDENTIFIERS,
SerializationFeature.WRAP_EXCEPTIONS
);
scfg = scfg.withoutFeatures(
SerializationFeature.CLOSE_CLOSEABLE,
SerializationFeature.EAGER_SERIALIZER_FETCH,
SerializationFeature.FAIL_ON_EMPTY_BEANS,
SerializationFeature.FLUSH_AFTER_WRITE_VALUE,
SerializationFeature.INDENT_OUTPUT,
SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS,
SerializationFeature.USE_EQUALITY_FOR_OBJECT_ID,
SerializationFeature.WRITE_CHAR_ARRAYS_AS_JSON_ARRAYS,
SerializationFeature.WRAP_ROOT_VALUE
);
mapper.setConfig(scfg);
DeserializationConfig dcfg = mapper.getDeserializationConfig();
dcfg = dcfg.withFeatures(
DeserializationFeature.ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT,
DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT,
DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY,
DeserializationFeature.FAIL_ON_INVALID_SUBTYPE,
DeserializationFeature.FAIL_ON_UNRESOLVED_OBJECT_IDS,
DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL,
DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS,
DeserializationFeature.WRAP_EXCEPTIONS
);
dcfg = dcfg.withoutFeatures(
DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES,
DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES,
DeserializationFeature.FAIL_ON_NUMBERS_FOR_ENUMS,
DeserializationFeature.FAIL_ON_READING_DUP_TREE_KEY,
DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES
);
mapper.setConfig(dcfg);
mapper.setSerializationInclusion(Include.NON_NULL); //NON_EMPTY?
mapper.enable(MapperFeature.ALLOW_FINAL_FIELDS_AS_MUTATORS);
mapper.enable(MapperFeature.AUTO_DETECT_FIELDS);
mapper.enable(MapperFeature.AUTO_DETECT_GETTERS);
mapper.enable(MapperFeature.AUTO_DETECT_IS_GETTERS);
mapper.enable(MapperFeature.AUTO_DETECT_SETTERS);
mapper.enable(MapperFeature.CAN_OVERRIDE_ACCESS_MODIFIERS);
mapper.enable(MapperFeature.USE_STD_BEAN_NAMING);
mapper.enable(MapperFeature.USE_ANNOTATIONS);
mapper.disable(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES);
mapper.disable(MapperFeature.AUTO_DETECT_CREATORS);
mapper.disable(MapperFeature.INFER_PROPERTY_MUTATORS);
mapper.disable(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY);
mapper.disable(MapperFeature.USE_GETTERS_AS_SETTERS);
mapper.disable(MapperFeature.USE_WRAPPER_NAME_AS_PROPERTY_NAME);
mapper.disable(MapperFeature.USE_STATIC_TYPING);
mapper.disable(MapperFeature.REQUIRE_SETTERS_FOR_GETTERS);
SimpleModule module = new SimpleModule();
module.addDeserializer(Void.class, new VoidDeserializer());
mapper.registerModule(module);
return mapper;
}