类 JacksonUtils
- java.lang.Object
-
- com.alibaba.nacos.common.utils.JacksonUtils
-
public final class JacksonUtils extends java.lang.ObjectJson utils implement by Jackson.- 作者:
- liaochuntao
-
-
字段概要
字段 修饰符和类型 字段 说明 (专用程序包) static com.fasterxml.jackson.databind.ObjectMappermapper
-
构造器概要
构造器 构造器 说明 JacksonUtils()
-
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static com.fasterxml.jackson.databind.JavaTypeconstructJavaType(java.lang.reflect.Type type)construct java type -> Jackson Java Type.static com.fasterxml.jackson.databind.node.ArrayNodecreateEmptyArrayNode()Create a new empty JacksonArrayNode.static com.fasterxml.jackson.databind.node.ObjectNodecreateEmptyJsonNode()Create a new empty JacksonObjectNode.static voidregisterSubtype(java.lang.Class<?> clz, java.lang.String type)Register sub type for child class.static java.lang.StringtoJson(java.lang.Object obj)Object to json string.static byte[]toJsonBytes(java.lang.Object obj)Object to json string byte array.static <T> TtoObj(byte[] json, com.fasterxml.jackson.core.type.TypeReference<T> typeReference)Json string deserialize to Object.static <T> TtoObj(byte[] json, java.lang.Class<T> cls)Json string deserialize to Object.static <T> TtoObj(byte[] json, java.lang.reflect.Type cls)Json string deserialize to Object.static <T> TtoObj(java.io.InputStream inputStream, java.lang.Class<T> cls)Json string deserialize to Object.static <T> TtoObj(java.io.InputStream inputStream, java.lang.reflect.Type type)Json string deserialize to Object.static com.fasterxml.jackson.databind.JsonNodetoObj(java.lang.String json)Json string deserialize to JacksonJsonNode.static <T> TtoObj(java.lang.String json, com.fasterxml.jackson.core.type.TypeReference<T> typeReference)Json string deserialize to Object.static <T> TtoObj(java.lang.String json, java.lang.Class<T> cls)Json string deserialize to Object.static <T> TtoObj(java.lang.String json, java.lang.reflect.Type type)Json string deserialize to Object.static com.fasterxml.jackson.databind.JsonNodetransferToJsonNode(java.lang.Object obj)Parse object to JacksonJsonNode.
-
-
-
方法详细资料
-
toJson
public static java.lang.String toJson(java.lang.Object obj)
Object to json string.- 参数:
obj- obj- 返回:
- json string
- 抛出:
com.alibaba.nacos.api.exception.runtime.NacosSerializationException- if transfer failed
-
toJsonBytes
public static byte[] toJsonBytes(java.lang.Object obj)
Object to json string byte array.- 参数:
obj- obj- 返回:
- json string byte array
- 抛出:
com.alibaba.nacos.api.exception.runtime.NacosSerializationException- if transfer failed
-
toObj
public static <T> T toObj(byte[] json, java.lang.Class<T> cls)Json string deserialize to Object.- 类型参数:
T- General type- 参数:
json- json stringcls- class of object- 返回:
- object
- 抛出:
com.alibaba.nacos.api.exception.runtime.NacosDeserializationException- if deserialize failed
-
toObj
public static <T> T toObj(byte[] json, java.lang.reflect.Type cls)Json string deserialize to Object.- 类型参数:
T- General type- 参数:
json- json stringcls-Typeof object- 返回:
- object
- 抛出:
com.alibaba.nacos.api.exception.runtime.NacosDeserializationException- if deserialize failed
-
toObj
public static <T> T toObj(java.io.InputStream inputStream, java.lang.Class<T> cls)Json string deserialize to Object.- 类型参数:
T- General type- 参数:
inputStream- json string input streamcls- class of object- 返回:
- object
- 抛出:
com.alibaba.nacos.api.exception.runtime.NacosDeserializationException- if deserialize failed
-
toObj
public static <T> T toObj(byte[] json, com.fasterxml.jackson.core.type.TypeReference<T> typeReference)Json string deserialize to Object.- 类型参数:
T- General type- 参数:
json- json string byte arraytypeReference-TypeReferenceof object- 返回:
- object
- 抛出:
com.alibaba.nacos.api.exception.runtime.NacosDeserializationException- if deserialize failed
-
toObj
public static <T> T toObj(java.lang.String json, java.lang.Class<T> cls)Json string deserialize to Object.- 类型参数:
T- General type- 参数:
json- json stringcls- class of object- 返回:
- object
- 抛出:
com.alibaba.nacos.api.exception.runtime.NacosDeserializationException- if deserialize failed
-
toObj
public static <T> T toObj(java.lang.String json, java.lang.reflect.Type type)Json string deserialize to Object.- 类型参数:
T- General type- 参数:
json- json stringtype-Typeof object- 返回:
- object
- 抛出:
com.alibaba.nacos.api.exception.runtime.NacosDeserializationException- if deserialize failed
-
toObj
public static <T> T toObj(java.lang.String json, com.fasterxml.jackson.core.type.TypeReference<T> typeReference)Json string deserialize to Object.- 类型参数:
T- General type- 参数:
json- json stringtypeReference-TypeReferenceof object- 返回:
- object
- 抛出:
com.alibaba.nacos.api.exception.runtime.NacosDeserializationException- if deserialize failed
-
toObj
public static <T> T toObj(java.io.InputStream inputStream, java.lang.reflect.Type type)Json string deserialize to Object.- 类型参数:
T- General type- 参数:
inputStream- json string input streamtype-Typeof object- 返回:
- object
- 抛出:
com.alibaba.nacos.api.exception.runtime.NacosDeserializationException- if deserialize failed
-
toObj
public static com.fasterxml.jackson.databind.JsonNode toObj(java.lang.String json)
Json string deserialize to JacksonJsonNode.- 参数:
json- json string- 返回:
JsonNode- 抛出:
com.alibaba.nacos.api.exception.runtime.NacosDeserializationException- if deserialize failed
-
registerSubtype
public static void registerSubtype(java.lang.Class<?> clz, java.lang.String type)Register sub type for child class.- 参数:
clz- child classtype- type name of child class
-
createEmptyJsonNode
public static com.fasterxml.jackson.databind.node.ObjectNode createEmptyJsonNode()
Create a new empty JacksonObjectNode.- 返回:
ObjectNode
-
createEmptyArrayNode
public static com.fasterxml.jackson.databind.node.ArrayNode createEmptyArrayNode()
Create a new empty JacksonArrayNode.- 返回:
ArrayNode
-
transferToJsonNode
public static com.fasterxml.jackson.databind.JsonNode transferToJsonNode(java.lang.Object obj)
Parse object to JacksonJsonNode.- 参数:
obj- object- 返回:
JsonNode
-
constructJavaType
public static com.fasterxml.jackson.databind.JavaType constructJavaType(java.lang.reflect.Type type)
construct java type -> Jackson Java Type.- 参数:
type- java type- 返回:
- JavaType
JavaType
-
-