疯狂的狮子li
2021-08-02 c813046594b82230cd2cb61622d68a4981096e08
ruoyi-common/src/main/java/com/ruoyi/common/utils/JsonUtils.java
@@ -1,7 +1,6 @@
package com.ruoyi.common.utils;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.StrUtil;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -32,6 +31,9 @@
    }
    public static String toJsonString(Object object) {
      if (StringUtils.isNull(object)) {
         return null;
      }
        try {
            return objectMapper.writeValueAsString(object);
        } catch (JsonProcessingException e) {
@@ -40,7 +42,7 @@
    }
    public static <T> T parseObject(String text, Class<T> clazz) {
        if (StrUtil.isEmpty(text)) {
        if (StringUtils.isEmpty(text)) {
            return null;
        }
        try {
@@ -62,6 +64,9 @@
    }
    public static <T> T parseObject(String text, TypeReference<T> typeReference) {
      if (StringUtils.isBlank(text)) {
         return null;
      }
        try {
            return objectMapper.readValue(text, typeReference);
        } catch (IOException e) {
@@ -70,6 +75,9 @@
    }
   public static <T> Map<String, T> parseMap(String text) {
      if (StringUtils.isBlank(text)) {
         return null;
      }
      try {
         return objectMapper.readValue(text, new TypeReference<Map<String, T>>() {});
      } catch (IOException e) {
@@ -78,7 +86,7 @@
   }
    public static <T> List<T> parseArray(String text, Class<T> clazz) {
        if (StrUtil.isEmpty(text)) {
        if (StringUtils.isEmpty(text)) {
            return new ArrayList<>();
        }
        try {