修复JSONUtil.toBean可能的空指针问题

This commit is contained in:
Looly
2023-03-17 01:00:19 +08:00
parent 6f8b4dd818
commit 23b74ed7bf
2 changed files with 7 additions and 2 deletions
+2 -1
View File
@@ -2,7 +2,7 @@
# 🚀Changelog
-------------------------------------------------------------------------------------------------------------
# 5.8.16.M1 (2023-03-14)
# 5.8.16.M1 (2023-03-17)
### 🐣新特性
* 【core 】 改进Calculator.conversion,兼容乘法符号省略写法(issue#2964@Github)
@@ -15,6 +15,7 @@
* 【core 】 修复BeanUtil.hasGetter没有跳过getClass方法的问题(issue#I6MBS5@Gitee)
* 【core 】 修复FileMagicNumber长度判断问题导致的越界异常(issue#I6MACI@Gitee)
* 【core 】 修复DateUtil针对ISO8601时间格式部分场景下的解析存在问题(issue#2981@Github)
* 【core 】 修复JSONUtil.toBean可能的空指针问题(issue#2987@Github)
-------------------------------------------------------------------------------------------------------------
# 5.8.15 (2023-03-09)
@@ -472,7 +472,11 @@ public class JSONUtil {
* @since 4.3.2
*/
public static <T> T toBean(String jsonString, Type beanType, boolean ignoreError) {
return parse(jsonString, JSONConfig.create().setIgnoreError(ignoreError)).toBean(beanType);
final JSON json = parse(jsonString, JSONConfig.create().setIgnoreError(ignoreError));
if(null == json){
return null;
}
return json.toBean(beanType);
}
/**