Browse Source

fix 修复 日志转换非json数据导致报错

疯狂的狮子li 2 years ago
parent
commit
7135a917c5
1 changed files with 4 additions and 0 deletions
  1. 4 0
      ruoyi-common/src/main/java/com/ruoyi/common/utils/JsonUtils.java

+ 4 - 0
ruoyi-common/src/main/java/com/ruoyi/common/utils/JsonUtils.java

@@ -6,6 +6,7 @@ import cn.hutool.core.util.ObjectUtil;
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.core.type.TypeReference;
 import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.exc.MismatchedInputException;
 import com.ruoyi.common.utils.spring.SpringUtils;
 import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
@@ -78,6 +79,9 @@ public class JsonUtils {
         }
         try {
             return OBJECT_MAPPER.readValue(text, OBJECT_MAPPER.getTypeFactory().constructType(Dict.class));
+        } catch (MismatchedInputException e) {
+            // 类型不匹配说明不是json
+            return null;
         } catch (IOException e) {
             throw new RuntimeException(e);
         }