This commit is contained in:
Looly
2022-06-16 19:19:56 +08:00
parent e491349b81
commit 40ff9f051e
26 changed files with 160 additions and 119 deletions

View File

@@ -1,7 +1,6 @@
package cn.hutool.json;
import cn.hutool.core.bean.BeanPath;
import cn.hutool.core.reflect.TypeReference;
import java.io.Serializable;
import java.io.StringWriter;
@@ -171,16 +170,4 @@ public interface JSON extends Cloneable, Serializable {
default <T> T toBean(final Type type) {
return JSONConverter.jsonConvert(type, this, getConfig());
}
/**
* 转为实体类对象,转换异常将被抛出
*
* @param <T> Bean类型
* @param reference {@link TypeReference}类型参考子类可以获取其泛型参数中的Type类型
* @return 实体类对象
* @since 4.2.2
*/
default <T> T toBean(final TypeReference<T> reference) {
return toBean(reference.getType());
}
}

View File

@@ -333,6 +333,10 @@ public class JSONUtil {
if (obj instanceof CharSequence) {
return StrUtil.str((CharSequence) obj);
}
if(obj instanceof Number){
return obj.toString();
}
return toJsonStr(parse(obj, jsonConfig));
}