add method

This commit is contained in:
Looly 2021-09-06 10:14:34 +08:00
parent 3b94a2da66
commit bea9196e09
2 changed files with 13 additions and 1 deletions

View File

@ -11,6 +11,7 @@
* 【core 】 BeanUtil.getProperty增加判空issue#I488HA@Gitee * 【core 】 BeanUtil.getProperty增加判空issue#I488HA@Gitee
* 【core 】 OptionalBean弃用pr#1182@Github * 【core 】 OptionalBean弃用pr#1182@Github
* 【setting】 Setting、Props持有URL改为持有Resourcepr#1182@Github * 【setting】 Setting、Props持有URL改为持有Resourcepr#1182@Github
* 【json 】 JSONUtil.toJsonStr增加重载支持JSONConfigissue#I48H5L@Gitee
### 🐞Bug修复 ### 🐞Bug修复
* 【core 】 修复ListUtil.split方法越界问题issue#I48Q0P@Gitee * 【core 】 修复ListUtil.split方法越界问题issue#I48Q0P@Gitee

View File

@ -349,13 +349,24 @@ public class JSONUtil {
* @return JSON字符串 * @return JSON字符串
*/ */
public static String toJsonStr(Object obj) { public static String toJsonStr(Object obj) {
return toJsonStr(obj, (JSONConfig) null);
}
/**
* 转换为JSON字符串
*
* @param obj 被转为JSON的对象
* @return JSON字符串
* @since 5.7.12
*/
public static String toJsonStr(Object obj, JSONConfig jsonConfig) {
if (null == obj) { if (null == obj) {
return null; return null;
} }
if (obj instanceof CharSequence) { if (obj instanceof CharSequence) {
return StrUtil.str((CharSequence) obj); return StrUtil.str((CharSequence) obj);
} }
return toJsonStr(parse(obj)); return toJsonStr(parse(obj, jsonConfig));
} }
/** /**