From 1668c3543bbeaf31d6b179e59bae6e985a25a491 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E6=B2=90?= Date: Mon, 1 Apr 2024 09:51:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/net/maku/framework/common/utils/JsonUtils.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/maku-framework/src/main/java/net/maku/framework/common/utils/JsonUtils.java b/maku-framework/src/main/java/net/maku/framework/common/utils/JsonUtils.java index 64e0409..73078c2 100644 --- a/maku-framework/src/main/java/net/maku/framework/common/utils/JsonUtils.java +++ b/maku-framework/src/main/java/net/maku/framework/common/utils/JsonUtils.java @@ -5,6 +5,7 @@ import cn.hutool.core.util.StrUtil; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import java.util.ArrayList; import java.util.List; @@ -19,9 +20,12 @@ public class JsonUtils { private static final ObjectMapper objectMapper = new ObjectMapper(); static { + objectMapper.registerModule(new JavaTimeModule()); +// objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); +// objectMapper.activateDefaultTyping(LaissezFaireSubTypeValidator.instance, ObjectMapper.DefaultTyping.NON_FINAL); objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); } - + public static String toJsonString(Object object) { try { return objectMapper.writeValueAsString(object);