public final class JacksonUtils extends Object
| 构造器和说明 |
|---|
JacksonUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static com.fasterxml.jackson.databind.JavaType |
constructJavaType(Type type)
construct java type -> Jackson Java Type.
|
static com.fasterxml.jackson.databind.node.ArrayNode |
createEmptyArrayNode()
Create a new empty Jackson
ArrayNode. |
static com.fasterxml.jackson.databind.node.ObjectNode |
createEmptyJsonNode()
Create a new empty Jackson
ObjectNode. |
static void |
registerSubtype(Class<?> clz,
String type)
Register sub type for child class.
|
static String |
toJson(Object obj)
Object to json string.
|
static byte[] |
toJsonBytes(Object obj)
Object to json string byte array.
|
static <T> T |
toObj(byte[] json,
Class<T> cls)
Json string deserialize to Object.
|
static <T> T |
toObj(byte[] json,
Type cls)
Json string deserialize to Object.
|
static <T> T |
toObj(byte[] json,
com.fasterxml.jackson.core.type.TypeReference<T> typeReference)
Json string deserialize to Object.
|
static <T> T |
toObj(InputStream inputStream,
Class<T> cls)
Json string deserialize to Object.
|
static <T> T |
toObj(InputStream inputStream,
Type type)
Json string deserialize to Object.
|
static com.fasterxml.jackson.databind.JsonNode |
toObj(String json)
Json string deserialize to Jackson
JsonNode. |
static <T> T |
toObj(String json,
Class<T> cls)
Json string deserialize to Object.
|
static <T> T |
toObj(String json,
Type type)
Json string deserialize to Object.
|
static <T> T |
toObj(String json,
com.fasterxml.jackson.core.type.TypeReference<T> typeReference)
Json string deserialize to Object.
|
static com.fasterxml.jackson.databind.JsonNode |
transferToJsonNode(Object obj)
Parse object to Jackson
JsonNode. |
public static String toJson(Object obj)
obj - objNacosSerializationException - if transfer failedpublic static byte[] toJsonBytes(Object obj)
obj - objNacosSerializationException - if transfer failedpublic static <T> T toObj(byte[] json,
Class<T> cls)
T - General typejson - json stringcls - class of objectNacosDeserializationException - if deserialize failedpublic static <T> T toObj(byte[] json,
Type cls)
T - General typejson - json stringcls - Type of objectNacosDeserializationException - if deserialize failedpublic static <T> T toObj(InputStream inputStream, Class<T> cls)
T - General typeinputStream - json string input streamcls - class of objectNacosDeserializationException - if deserialize failedpublic static <T> T toObj(byte[] json,
com.fasterxml.jackson.core.type.TypeReference<T> typeReference)
T - General typejson - json string byte arraytypeReference - TypeReference of objectNacosDeserializationException - if deserialize failedpublic static <T> T toObj(String json, Class<T> cls)
T - General typejson - json stringcls - class of objectNacosDeserializationException - if deserialize failedpublic static <T> T toObj(String json, Type type)
T - General typejson - json stringtype - Type of objectNacosDeserializationException - if deserialize failedpublic static <T> T toObj(String json, com.fasterxml.jackson.core.type.TypeReference<T> typeReference)
T - General typejson - json stringtypeReference - TypeReference of objectNacosDeserializationException - if deserialize failedpublic static <T> T toObj(InputStream inputStream, Type type)
T - General typeinputStream - json string input streamtype - Type of objectNacosDeserializationException - if deserialize failedpublic static com.fasterxml.jackson.databind.JsonNode toObj(String json)
JsonNode.json - json stringJsonNodeNacosDeserializationException - if deserialize failedpublic static void registerSubtype(Class<?> clz, String type)
clz - child classtype - type name of child classpublic static com.fasterxml.jackson.databind.node.ObjectNode createEmptyJsonNode()
ObjectNode.ObjectNodepublic static com.fasterxml.jackson.databind.node.ArrayNode createEmptyArrayNode()
ArrayNode.ArrayNodepublic static com.fasterxml.jackson.databind.JsonNode transferToJsonNode(Object obj)
JsonNode.obj - objectJsonNodepublic static com.fasterxml.jackson.databind.JavaType constructJavaType(Type type)
type - java typeJavaTypeCopyright © 2018–2022 Alibaba Group. All rights reserved.