From 96a75cd2e43b886d5a4c54eb623b3c29ad5ebb33 Mon Sep 17 00:00:00 2001 From: Looly Date: Fri, 10 Oct 2025 22:12:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0Record=E6=94=AF=E6=8C=81?= =?UTF-8?q?=EF=BC=88pr#4096@Github=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + hutool-json/src/main/java/cn/hutool/json/ObjectMapper.java | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd6379237..20063b37e 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ * 【extra 】 `PinyinUtil`增加判空(pr#4081@Github) * 【core 】 `LocalDateTimeUtil.parseDate`注释修正(pr#4085@Github) * 【core 】 `StrUtil`增加null检查处理(pr#4086@Github) +* 【json 】 增加Record支持(pr#4096@Github) ### 🐞Bug修复 * 【core 】 修复`ReflectUtil`中因class和Method关联导致的缓存无法回收问题(issue#4039@Github) diff --git a/hutool-json/src/main/java/cn/hutool/json/ObjectMapper.java b/hutool-json/src/main/java/cn/hutool/json/ObjectMapper.java index 81378cba1..1425f2ad3 100755 --- a/hutool-json/src/main/java/cn/hutool/json/ObjectMapper.java +++ b/hutool-json/src/main/java/cn/hutool/json/ObjectMapper.java @@ -109,12 +109,12 @@ public class ObjectMapper { } else if (source instanceof ResourceBundle) { // JSONTokener mapFromResourceBundle((ResourceBundle) source, jsonObject, filter); + } else if (RecordUtil.isRecord(source.getClass())) { + mapFromBean(source, jsonObject); } else if (BeanUtil.isReadableBean(source.getClass())) { // 普通Bean // TODO 过滤器对Bean无效,需补充。 mapFromBean(source, jsonObject); - } else if (RecordUtil.isRecord(source.getClass())) { - mapFromBean(source, jsonObject); } // 跳过空对象