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); } // 跳过空对象