mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-08-18 20:38:02 +08:00
fix test
This commit is contained in:
@@ -201,7 +201,7 @@ public final class InternalJSONUtil {
|
||||
static Map<String, Object> createRawMap(final int capacity, JSONConfig config) {
|
||||
final Map<String, Object> rawHashMap;
|
||||
if (null == config) {
|
||||
config = JSONConfig.create();
|
||||
config = JSONConfig.of();
|
||||
}
|
||||
final Comparator<String> keyComparator = config.getKeyComparator();
|
||||
if (config.isIgnoreCase()) {
|
||||
|
||||
@@ -2,6 +2,8 @@ package cn.hutool.json;
|
||||
|
||||
import cn.hutool.core.bean.BeanPath;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.convert.impl.ArrayConverter;
|
||||
import cn.hutool.core.lang.func.Filter;
|
||||
import cn.hutool.core.lang.mutable.Mutable;
|
||||
import cn.hutool.core.lang.mutable.MutableObj;
|
||||
@@ -66,7 +68,7 @@ public class JSONArray implements JSON, JSONGetter<Integer>, List<Object>, Rando
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public JSONArray(final int initialCapacity) {
|
||||
this(initialCapacity, JSONConfig.create());
|
||||
this(initialCapacity, JSONConfig.of());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,7 +92,7 @@ public class JSONArray implements JSON, JSONGetter<Integer>, List<Object>, Rando
|
||||
*/
|
||||
public JSONArray(final int initialCapacity, final JSONConfig config) {
|
||||
this.rawList = new ArrayList<>(initialCapacity);
|
||||
this.config = ObjUtil.defaultIfNull(config, JSONConfig::create);
|
||||
this.config = ObjUtil.defaultIfNull(config, JSONConfig::of);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -107,7 +109,7 @@ public class JSONArray implements JSON, JSONGetter<Integer>, List<Object>, Rando
|
||||
* @throws JSONException 非数组或集合
|
||||
*/
|
||||
public JSONArray(final Object object) throws JSONException {
|
||||
this(object, JSONConfig.create());
|
||||
this(object, JSONConfig.of());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -332,7 +334,7 @@ public class JSONArray implements JSON, JSONGetter<Integer>, List<Object>, Rando
|
||||
@Override
|
||||
@SuppressWarnings({"unchecked"})
|
||||
public <T> T[] toArray(final T[] a) {
|
||||
return (T[]) JSONConverter.toArray(this, a.getClass().getComponentType());
|
||||
return (T[]) ArrayConverter.INSTANCE.convert(a.getClass().getComponentType(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -481,7 +483,7 @@ public class JSONArray implements JSON, JSONGetter<Integer>, List<Object>, Rando
|
||||
* @return 实体类对象
|
||||
*/
|
||||
public Object toArray(final Class<?> arrayClass) {
|
||||
return JSONConverter.toArray(this, arrayClass);
|
||||
return ArrayConverter.INSTANCE.convert(arrayClass, this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -493,7 +495,7 @@ public class JSONArray implements JSON, JSONGetter<Integer>, List<Object>, Rando
|
||||
* @since 3.0.8
|
||||
*/
|
||||
public <T> List<T> toList(final Class<T> elementType) {
|
||||
return JSONConverter.toList(this, elementType);
|
||||
return Convert.toList(elementType, this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -49,7 +49,7 @@ public class JSONConfig implements Serializable {
|
||||
*
|
||||
* @return JSONConfig
|
||||
*/
|
||||
public static JSONConfig create() {
|
||||
public static JSONConfig of() {
|
||||
return new JSONConfig();
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.convert.ConvertException;
|
||||
import cn.hutool.core.convert.Converter;
|
||||
import cn.hutool.core.convert.ConverterRegistry;
|
||||
import cn.hutool.core.convert.impl.ArrayConverter;
|
||||
import cn.hutool.core.convert.impl.BeanConverter;
|
||||
import cn.hutool.core.reflect.ConstructorUtil;
|
||||
import cn.hutool.core.reflect.TypeUtil;
|
||||
@@ -16,7 +15,6 @@ import cn.hutool.json.serialize.GlobalSerializeMapping;
|
||||
import cn.hutool.json.serialize.JSONDeserializer;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* JSON转换器
|
||||
@@ -41,29 +39,6 @@ public class JSONConverter implements Converter {
|
||||
return JSONUtil.parse(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* JSONArray转数组
|
||||
*
|
||||
* @param jsonArray JSONArray
|
||||
* @param arrayClass 数组元素类型
|
||||
* @return 数组对象
|
||||
*/
|
||||
protected static Object toArray(final JSONArray jsonArray, final Class<?> arrayClass) {
|
||||
return ArrayConverter.INSTANCE.convert(arrayClass, jsonArray, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将JSONArray转换为指定类型的对量列表
|
||||
*
|
||||
* @param <T> 元素类型
|
||||
* @param jsonArray JSONArray
|
||||
* @param elementType 对象元素类型
|
||||
* @return 对象列表
|
||||
*/
|
||||
protected static <T> List<T> toList(final JSONArray jsonArray, final Class<T> elementType) {
|
||||
return Convert.toList(elementType, jsonArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* JSON递归转换<br>
|
||||
* 首先尝试JDK类型转换,如果失败尝试JSON转Bean<br>
|
||||
|
||||
@@ -46,7 +46,7 @@ public class JSONObject extends MapWrapper<String, Object> implements JSON, JSON
|
||||
* 构造,初始容量为 {@link #DEFAULT_CAPACITY},KEY有序
|
||||
*/
|
||||
public JSONObject() {
|
||||
this(JSONConfig.create());
|
||||
this(JSONConfig.of());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,8 +67,8 @@ public class JSONObject extends MapWrapper<String, Object> implements JSON, JSON
|
||||
* @since 4.1.19
|
||||
*/
|
||||
public JSONObject(final int capacity, final JSONConfig config) {
|
||||
super(InternalJSONUtil.createRawMap(capacity, ObjUtil.defaultIfNull(config, JSONConfig.create())));
|
||||
this.config = ObjUtil.defaultIfNull(config, JSONConfig.create());
|
||||
super(InternalJSONUtil.createRawMap(capacity, ObjUtil.defaultIfNull(config, JSONConfig.of())));
|
||||
this.config = ObjUtil.defaultIfNull(config, JSONConfig.of());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,7 +84,7 @@ public class JSONObject extends MapWrapper<String, Object> implements JSON, JSON
|
||||
* @param source JavaBean或者Map对象或者String
|
||||
*/
|
||||
public JSONObject(final Object source) {
|
||||
this(source, JSONConfig.create().setIgnoreNullValue(InternalJSONUtil.defaultIgnoreNullValue(source)));
|
||||
this(source, JSONConfig.of().setIgnoreNullValue(InternalJSONUtil.defaultIgnoreNullValue(source)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -113,7 +113,7 @@ public class JSONUtil {
|
||||
* @since 3.0.9
|
||||
*/
|
||||
public static JSONObject parseObj(final Object obj, final boolean ignoreNullValue) {
|
||||
return new JSONObject(obj, JSONConfig.create().setIgnoreNullValue(ignoreNullValue));
|
||||
return new JSONObject(obj, JSONConfig.of().setIgnoreNullValue(ignoreNullValue));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -148,7 +148,7 @@ public class JSONUtil {
|
||||
* @since 3.2.3
|
||||
*/
|
||||
public static JSONArray parseArray(final Object arrayOrCollection, final boolean ignoreNullValue) {
|
||||
return new JSONArray(arrayOrCollection, JSONConfig.create().setIgnoreNullValue(ignoreNullValue));
|
||||
return new JSONArray(arrayOrCollection, JSONConfig.of().setIgnoreNullValue(ignoreNullValue));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -438,7 +438,7 @@ public class JSONUtil {
|
||||
* @since 4.3.2
|
||||
*/
|
||||
public static <T> T toBean(final String jsonString, final Type beanType, final boolean ignoreError) {
|
||||
return parse(jsonString, JSONConfig.create().setIgnoreError(ignoreError)).toBean(beanType);
|
||||
return parse(jsonString, JSONConfig.of().setIgnoreError(ignoreError)).toBean(beanType);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,7 +21,7 @@ public class Claims implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
// 时间使用秒级时间戳表示
|
||||
private final JSONConfig CONFIG = JSONConfig.create().setDateFormat("#sss");
|
||||
private final JSONConfig CONFIG = JSONConfig.of().setDateFormat("#sss");
|
||||
|
||||
private JSONObject claimJSON;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user