diff --git a/maku-framework/src/main/java/net/maku/framework/common/utils/AddressUtils.java b/maku-framework/src/main/java/net/maku/framework/common/utils/AddressUtils.java index ea9626d..e45d1bf 100644 --- a/maku-framework/src/main/java/net/maku/framework/common/utils/AddressUtils.java +++ b/maku-framework/src/main/java/net/maku/framework/common/utils/AddressUtils.java @@ -1,7 +1,6 @@ package net.maku.framework.common.utils; import cn.hutool.http.HttpUtil; -import cn.hutool.json.JSONUtil; import lombok.Data; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; @@ -36,7 +35,7 @@ public class AddressUtils { return UNKNOWN; } - Address address = JSONUtil.toBean(response, Address.class); + Address address = JsonUtils.parseObject(response, Address.class); return String.format("%s %s", address.getPro(), address.getCity()); } catch (Exception e) { log.error("根据IP获取地址异常 {}", ip); diff --git a/maku-framework/src/main/java/net/maku/framework/common/utils/JsonUtils.java b/maku-framework/src/main/java/net/maku/framework/common/utils/JsonUtils.java index 89d99af..485858f 100644 --- a/maku-framework/src/main/java/net/maku/framework/common/utils/JsonUtils.java +++ b/maku-framework/src/main/java/net/maku/framework/common/utils/JsonUtils.java @@ -3,6 +3,7 @@ package net.maku.framework.common.utils; import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.StrUtil; import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import java.util.ArrayList; @@ -16,6 +17,10 @@ import java.util.List; public class JsonUtils { private static final ObjectMapper objectMapper = new ObjectMapper(); + static { + objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + } + public static String toJsonString(Object object) { try { return objectMapper.writeValueAsString(object);