mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix code
This commit is contained in:
@@ -203,9 +203,18 @@ public class JSONObject extends MapWrapper<String, Object> implements JSON, JSON
|
||||
return getOrDefault(key, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object get(final Object key) {
|
||||
Object value = super.get(key);
|
||||
if(value instanceof JSONPrimitive){
|
||||
value = ((JSONPrimitive) value).getValue();
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOrDefault(final Object key, final Object defaultValue) {
|
||||
Object value = super.getOrDefault(key, defaultValue);
|
||||
Object value = super.getOrDefault(key, defaultValue);
|
||||
if(value instanceof JSONPrimitive){
|
||||
value = ((JSONPrimitive) value).getValue();
|
||||
}
|
||||
|
@@ -18,10 +18,7 @@ package org.dromara.hutool.json.mapper;
|
||||
|
||||
import org.dromara.hutool.core.array.ArrayUtil;
|
||||
import org.dromara.hutool.core.util.ObjUtil;
|
||||
import org.dromara.hutool.json.JSON;
|
||||
import org.dromara.hutool.json.JSONArray;
|
||||
import org.dromara.hutool.json.JSONConfig;
|
||||
import org.dromara.hutool.json.JSONObject;
|
||||
import org.dromara.hutool.json.*;
|
||||
import org.dromara.hutool.json.serializer.JSONStringer;
|
||||
import org.dromara.hutool.json.writer.GlobalValueWriters;
|
||||
|
||||
@@ -91,6 +88,10 @@ public class JSONValueMapper implements Serializable {
|
||||
|| object instanceof CharSequence //
|
||||
|| ObjUtil.isBasicType(object) //
|
||||
) {
|
||||
if(object instanceof JSONPrimitive){
|
||||
return ((JSONPrimitive) object).getValue();
|
||||
}
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
|
@@ -183,14 +183,14 @@ public class JSONParser {
|
||||
tokener.nextColon();
|
||||
|
||||
// 过滤并设置键值对
|
||||
Object value = parse();
|
||||
JSON value = parse();
|
||||
// 添加前置过滤,通过MutablePair实现过滤、修改键值对等
|
||||
if (null != predicate) {
|
||||
final MutableEntry<Object, Object> pair = new MutableEntry<>(key, value);
|
||||
if (predicate.test(pair)) {
|
||||
final MutableEntry<Object, Object> entry = new MutableEntry<>(key, value);
|
||||
if (predicate.test(entry)) {
|
||||
// 使用修改后的键值对
|
||||
key = (String) pair.getKey();
|
||||
value = pair.getValue();
|
||||
key = (String) entry.getKey();
|
||||
value = (JSON) entry.getValue();
|
||||
jsonObject.set(key, value);
|
||||
}
|
||||
}else {
|
||||
|
@@ -16,11 +16,11 @@
|
||||
|
||||
package org.dromara.hutool.json.serializer.impl;
|
||||
|
||||
import org.dromara.hutool.core.convert.impl.TemporalAccessorConverter;
|
||||
import org.dromara.hutool.core.lang.Assert;
|
||||
import org.dromara.hutool.core.lang.Opt;
|
||||
import org.dromara.hutool.core.math.NumberUtil;
|
||||
import org.dromara.hutool.json.JSON;
|
||||
import org.dromara.hutool.json.JSONException;
|
||||
import org.dromara.hutool.json.JSONObject;
|
||||
import org.dromara.hutool.json.*;
|
||||
import org.dromara.hutool.json.serializer.JSONContext;
|
||||
import org.dromara.hutool.json.serializer.JSONDeserializer;
|
||||
import org.dromara.hutool.json.serializer.JSONSerializer;
|
||||
@@ -101,6 +101,17 @@ public class TemporalAccessorSerializer implements JSONSerializer<TemporalAccess
|
||||
|
||||
@Override
|
||||
public TemporalAccessor deserialize(final JSON json, final Type deserializeType) {
|
||||
// JSONPrimitive
|
||||
if(json instanceof JSONPrimitive){
|
||||
final Object value = ((JSONPrimitive) json).getValue();
|
||||
final TemporalAccessorConverter converter = new TemporalAccessorConverter(
|
||||
Opt.ofNullable(json.config()).map(JSONConfig::getDateFormat).getOrNull());
|
||||
return (TemporalAccessor) converter.convert(deserializeType, value);
|
||||
}
|
||||
|
||||
// TODO JSONArray
|
||||
|
||||
// JSONObject
|
||||
final JSONObject jsonObject = (JSONObject) json;
|
||||
if (LocalDate.class.equals(this.temporalAccessorClass) || LocalDateTime.class.equals(this.temporalAccessorClass)) {
|
||||
// 年
|
||||
|
Reference in New Issue
Block a user