public final class JsonUtil extends Object
| 限定符和类型 | 方法和说明 |
|---|---|
static <T> T |
convertValue(Object obj,
Class<T> valueType)
将对象转为另一个类型的对象
|
static <T> T |
convertValue(Object obj,
com.fasterxml.jackson.core.type.TypeReference<T> valueTypeRef)
将对象转为另一个复杂嵌套类型的对象
|
static com.fasterxml.jackson.databind.ObjectMapper |
getObjectMapper()
获取当前默认的ObjectMapper,可以对它设置,并且实时生效的
|
static com.fasterxml.jackson.databind.ObjectMapper |
newObjectMapper()
每次获取一个新的ObjectMapper,可以自定义解析配置
|
static <T> T |
readValue(String content,
Class<T> valueType)
将JsonString转为对象
|
static <T> T |
readValue(String content,
com.fasterxml.jackson.core.type.TypeReference<T> valueTypeRef)
将JsonString转为复杂嵌套的对象
|
static String |
toJsonString(Object obj,
boolean pretty)
将对象转为JsonString
|
static String |
toNoNullJsonStr(Object obj,
boolean pretty)
将对象转为JsonString,不包含为null的字段
|
public static com.fasterxml.jackson.databind.ObjectMapper newObjectMapper()
public static com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
public static <T> T readValue(String content, Class<T> valueType)
content - valueType - public static <T> T readValue(String content, com.fasterxml.jackson.core.type.TypeReference<T> valueTypeRef)
content - valueTypeRef - public static <T> T convertValue(Object obj, Class<T> valueType)
obj - valueType - public static <T> T convertValue(Object obj, com.fasterxml.jackson.core.type.TypeReference<T> valueTypeRef)
obj - valueTypeRef - public static String toJsonString(Object obj, boolean pretty)
obj - pretty - 是否美化、格式化jsonCopyright © 2020. All rights reserved.