1
0
mirror of https://github.com/chillzhuang/blade-tool synced 2025-04-29 07:49:50 +08:00

jackson序列化时支持空字符串转换为null对象

This commit is contained in:
smallchill 2024-12-10 18:58:55 +08:00
parent 9d7400f381
commit 542413373f
2 changed files with 4 additions and 0 deletions
blade-core-tool/src/main/java/org/springblade/core/tool

@ -77,6 +77,8 @@ public class JacksonConfiguration {
objectMapper.getDeserializationConfig().withoutFeatures(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
//日期格式化
objectMapper.registerModule(new BladeJavaTimeModule());
//允许空字符串序列化为null对象
objectMapper.enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT);
objectMapper.findAndRegisterModules();
return objectMapper;
}

@ -976,6 +976,8 @@ public class JsonUtil {
super.getDeserializationConfig().withoutFeatures(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
//日期格式化
super.registerModule(new BladeJavaTimeModule());
//允许空字符串序列化为null对象
super.enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT);
super.findAndRegisterModules();
}