From 542413373f01bd6bda80390991ae7a60e4c42178 Mon Sep 17 00:00:00 2001 From: smallchill Date: Tue, 10 Dec 2024 18:58:55 +0800 Subject: [PATCH] =?UTF-8?q?:zap:=20jackson=E5=BA=8F=E5=88=97=E5=8C=96?= =?UTF-8?q?=E6=97=B6=E6=94=AF=E6=8C=81=E7=A9=BA=E5=AD=97=E7=AC=A6=E4=B8=B2?= =?UTF-8?q?=E8=BD=AC=E6=8D=A2=E4=B8=BAnull=E5=AF=B9=E8=B1=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/springblade/core/tool/config/JacksonConfiguration.java | 2 ++ .../main/java/org/springblade/core/tool/jackson/JsonUtil.java | 2 ++ 2 files changed, 4 insertions(+) diff --git a/blade-core-tool/src/main/java/org/springblade/core/tool/config/JacksonConfiguration.java b/blade-core-tool/src/main/java/org/springblade/core/tool/config/JacksonConfiguration.java index e60e4b5..a716598 100644 --- a/blade-core-tool/src/main/java/org/springblade/core/tool/config/JacksonConfiguration.java +++ b/blade-core-tool/src/main/java/org/springblade/core/tool/config/JacksonConfiguration.java @@ -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; } diff --git a/blade-core-tool/src/main/java/org/springblade/core/tool/jackson/JsonUtil.java b/blade-core-tool/src/main/java/org/springblade/core/tool/jackson/JsonUtil.java index 6b2e030..5759390 100644 --- a/blade-core-tool/src/main/java/org/springblade/core/tool/jackson/JsonUtil.java +++ b/blade-core-tool/src/main/java/org/springblade/core/tool/jackson/JsonUtil.java @@ -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(); }