类 JsonUtil


  • public class JsonUtil
    extends Object
    json 工具类
    作者:
    zhanglinfeng
    • 构造器详细资料

      • JsonUtil

        public JsonUtil()
    • 方法详细资料

      • getObjectMapper

        public static com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
        获取objectMapper
        返回:
        ObjectMapper
      • toJson

        public static <T> String toJson​(T t)
        对象转json
        类型参数:
        T -
        参数:
        t -
        返回:
      • toJsonBase64

        public static <T> String toJsonBase64​(T t)
        对象转换json之后转换base64
        类型参数:
        T -
        参数:
        t -
        返回:
      • toObject

        public static <T> T toObject​(String json,
                                     Class<T> clazz)
        json 转对象
        类型参数:
        T -
        参数:
        json -
        clazz -
        返回:
      • toObjectByBase64Json

        public static <T> T toObjectByBase64Json​(String base64Json,
                                                 Class<T> clazz)
        将base64的json字符串转换为对象
        类型参数:
        T - 类型
        参数:
        base64Json - base64字符串
        clazz - 对象类型
        返回:
      • toObject

        public static <T> T toObject​(String json,
                                     com.fasterxml.jackson.core.type.TypeReference<T> valueTypeRef)
        转换对象
        类型参数:
        T -
        参数:
        json -
        valueTypeRef -
        返回:
      • object2Map

        public static Map<String,​?> object2Map​(Object obj)
        对象转换为map
        参数:
        obj -
        返回:
      • jsonString2MapObj

        public static Map<String,​Object> jsonString2MapObj​(String jsonStr)
        对象转换为map
        参数:
        jsonStr -
        返回: