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

@@ -349,13 +349,24 @@ public class JSONUtil {
* @return JSON字符串
*/
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) {
return null;
}
if (obj instanceof CharSequence) {
return StrUtil.str((CharSequence) obj);
}
return toJsonStr(parse(obj));
return toJsonStr(parse(obj, jsonConfig));
}
/**