This commit is contained in:
Looly 2022-09-05 10:33:39 +08:00
parent 11724c8761
commit ff8b9f47ca
4 changed files with 10 additions and 14 deletions

View File

@ -199,7 +199,7 @@ public final class InternalJSONUtil {
* @return Map * @return Map
*/ */
static Map<String, Object> createRawMap(int capacity, JSONConfig config) { static Map<String, Object> createRawMap(int capacity, JSONConfig config) {
Map<String, Object> rawHashMap; final Map<String, Object> rawHashMap;
if (null == config) { if (null == config) {
config = JSONConfig.create(); config = JSONConfig.create();
} }

View File

@ -15,6 +15,14 @@ import java.lang.reflect.Type;
*/ */
public interface JSON extends Cloneable, Serializable { public interface JSON extends Cloneable, Serializable {
/**
* 获取JSON配置
*
* @return {@link JSONConfig}
* @since 5.8.6
*/
JSONConfig getConfig();
/** /**
* 通过表达式获取JSON中嵌套的对象<br> * 通过表达式获取JSON中嵌套的对象<br>
* <ol> * <ol>
@ -169,7 +177,7 @@ public interface JSON extends Cloneable, Serializable {
* @since 3.0.8 * @since 3.0.8
*/ */
default <T> T toBean(Type type) { default <T> T toBean(Type type) {
return toBean(type, false); return toBean(type, getConfig().isIgnoreError());
} }
/** /**

View File

@ -12,7 +12,6 @@ import cn.hutool.json.serialize.JSONWriter;
import java.io.StringWriter; import java.io.StringWriter;
import java.io.Writer; import java.io.Writer;
import java.lang.reflect.Type;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Iterator; import java.util.Iterator;
@ -262,11 +261,6 @@ public class JSONArray implements JSON, JSONGetter<Integer>, List<Object>, Rando
return this; return this;
} }
@Override
public <T> T toBean(Type type) {
return JSON.super.toBean(type, config.isIgnoreError());
}
/** /**
* 根据给定名列表与其位置对应的值组成JSONObject * 根据给定名列表与其位置对应的值组成JSONObject
* *

View File

@ -14,7 +14,6 @@ import cn.hutool.json.serialize.JSONWriter;
import java.io.StringWriter; import java.io.StringWriter;
import java.io.Writer; import java.io.Writer;
import java.lang.reflect.Type;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.BigInteger; import java.math.BigInteger;
import java.util.Collection; import java.util.Collection;
@ -284,11 +283,6 @@ public class JSONObject extends MapWrapper<String, Object> implements JSON, JSON
return this; return this;
} }
@Override
public <T> T toBean(Type type) {
return JSON.super.toBean(type, this.config.isIgnoreError());
}
/** /**
* 将指定KEY列表的值组成新的JSONArray * 将指定KEY列表的值组成新的JSONArray
* *