修复JSONUtil.toBean()中将JSON数组字符串转Map对象返回错误问题(issue#3795@Github)

This commit is contained in:
Looly
2024-11-24 16:01:28 +08:00
parent d11693fb2d
commit 50807c84d6
3 changed files with 23 additions and 0 deletions

View File

@@ -74,6 +74,11 @@ public class MapConverter extends AbstractConverter<Map<?, ?>> {
}
convertMapToMap((Map) value, map);
} else if (BeanUtil.isBean(value.getClass())) {
if(value.getClass().getName().equals("cn.hutool.json.JSONArray")){
// issue#3795 增加JSONArray转Map错误检查
throw new UnsupportedOperationException(StrUtil.format("Unsupported {} to Map.", value.getClass().getName()));
}
map = BeanUtil.beanToMap(value);
// 二次转换,转换键值类型
map = convertInternal(map);