From 24681c81c09022f584a57006f2534b5f74723414 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期二, 30 六月 2026 09:27:31 +0800
Subject: [PATCH] 初始化项目

---
 yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/json/JsonUtils.java |   29 +++++++++++++++++++++++++++--
 1 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/json/JsonUtils.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/json/JsonUtils.java
index c12e262..558c8d2 100644
--- a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/json/JsonUtils.java
+++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/json/JsonUtils.java
@@ -22,6 +22,7 @@
 import java.time.LocalDateTime;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 /**
  * JSON 宸ュ叿绫�
@@ -36,13 +37,12 @@
 
     private static ObjectMapper buildObjectMapper() {
         SimpleModule simpleModule = new SimpleModule()
+                // 瑙e喅 LocalDateTime 鐨勫簭鍒楀寲
                 .addSerializer(LocalDateTime.class, TimestampLocalDateTimeSerializer.INSTANCE)
                 .addDeserializer(LocalDateTime.class, TimestampLocalDateTimeDeserializer.INSTANCE);
         return JsonMapper.builder()
                 .disable(SerializationFeature.FAIL_ON_EMPTY_BEANS)
                 .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
-                // 寮哄埗灏嗘暣鏁板弽搴忓垪鍖栦负 Long锛岃В鍐� Redis 缂撳瓨鍙嶅簭鍒楀寲鏃� Integer 杞� Long 鐨勯棶棰�
-                .enable(DeserializationFeature.USE_LONG_FOR_INTS)
                 .changeDefaultPropertyInclusion(value -> JsonInclude.Value.construct(JsonInclude.Include.NON_NULL, JsonInclude.Include.NON_NULL))
                 .addModule(simpleModule)
                 .build();
@@ -177,6 +177,23 @@
     }
 
     /**
+     * 瑙f瀽 JSON 瀛楃涓叉垚 Map锛岀┖瀛楃涓叉垨瑙f瀽澶辫触杩斿洖 null
+     *
+     * @param text JSON 瀛楃涓�
+     * @return Map 瀵硅薄
+     */
+    public static Map<String, Object> parseMap(String text) {
+        if (StrUtil.isEmpty(text)) {
+            return null;
+        }
+        try {
+            return objectMapper.readValue(text, new TypeReference<Map<String, Object>>() {});
+        } catch (JacksonException e) {
+            return null;
+        }
+    }
+
+    /**
      * 瑙f瀽 JSON 瀛楃涓叉垚鎸囧畾绫诲瀷鐨勫璞★紝濡傛灉瑙f瀽澶辫触锛屽垯杩斿洖 null
      *
      * @param text 瀛楃涓�
@@ -238,6 +255,14 @@
         }
     }
 
+    public static String getText(JsonNode node, String fieldName) {
+        if (node == null) {
+            return null;
+        }
+        JsonNode value = node.get(fieldName);
+        return value != null && !value.isNull() ? value.asText() : null;
+    }
+
     public static boolean isJson(String text) {
         return JSONUtil.isTypeJSON(text);
     }

--
Gitblit v1.9.3