| | |
| | | |
| | | import cn.hutool.core.lang.Validator; |
| | | 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; |
| | |
| | | } |
| | | |
| | | public static String toJsonString(Object object) { |
| | | if (Validator.isEmpty(object)) { |
| | | if (StringUtils.isNull(object)) { |
| | | return null; |
| | | } |
| | | try { |
| | |
| | | } |
| | | |
| | | public static <T> T parseObject(String text, Class<T> clazz) { |
| | | if (StrUtil.isEmpty(text)) { |
| | | if (StringUtils.isEmpty(text)) { |
| | | return null; |
| | | } |
| | | try { |
| | |
| | | } |
| | | |
| | | public static <T> T parseObject(String text, TypeReference<T> typeReference) { |
| | | if (StrUtil.isBlank(text)) { |
| | | if (StringUtils.isBlank(text)) { |
| | | return null; |
| | | } |
| | | try { |
| | |
| | | } |
| | | |
| | | public static <T> Map<String, T> parseMap(String text) { |
| | | if (StrUtil.isBlank(text)) { |
| | | if (StringUtils.isBlank(text)) { |
| | | return null; |
| | | } |
| | | try { |
| | |
| | | } |
| | | |
| | | public static <T> List<T> parseArray(String text, Class<T> clazz) { |
| | | if (StrUtil.isEmpty(text)) { |
| | | if (StringUtils.isEmpty(text)) { |
| | | return new ArrayList<>(); |
| | | } |
| | | try { |