修复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

View File

@@ -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);
}
/**