类 JacksonUtils
java.lang.Object
com.alibaba.nacos.common.utils.JacksonUtils
Json utils implement by Jackson.
- 作者:
- liaochuntao
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static com.fasterxml.jackson.databind.JavaTypeconstructJavaType(Type type)construct java type -> Jackson Java Type.static com.fasterxml.jackson.databind.node.ArrayNodeCreate a new empty JacksonArrayNode.static com.fasterxml.jackson.databind.node.ObjectNodeCreate a new empty JacksonObjectNode.static voidregisterSubtype(Class<?> clz, String type)Register sub type for child class.static StringObject to json string.static byte[]toJsonBytes(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> TJson string deserialize to Object.static <T> TJson string deserialize to Object.static <T> TtoObj(InputStream inputStream, Class<T> cls)Json string deserialize to Object.static <T> TtoObj(InputStream inputStream, Type type)Json string deserialize to Object.static com.fasterxml.jackson.databind.JsonNodeJson string deserialize to JacksonJsonNode.static <T> TJson string deserialize to Object.static <T> TJson string deserialize to Object.static <T> TJson string deserialize to Object.static com.fasterxml.jackson.databind.JsonNodetransferToJsonNode(Object obj)Parse object to JacksonJsonNode.
-
构造器详细资料
-
JacksonUtils
public JacksonUtils()
-
-
方法详细资料
-
toJson
Object to json string.- 参数:
obj- obj- 返回:
- json string
- 抛出:
com.alibaba.nacos.api.exception.runtime.NacosSerializationException- if transfer failed
-
toJsonBytes
Object to json string byte array.- 参数:
obj- obj- 返回:
- json string byte array
- 抛出:
com.alibaba.nacos.api.exception.runtime.NacosSerializationException- if transfer failed
-
toObj
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
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
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
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
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(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
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
Json string deserialize to JacksonJsonNode.- 参数:
json- json string- 返回:
JsonNode- 抛出:
com.alibaba.nacos.api.exception.runtime.NacosDeserializationException- if deserialize failed
-
registerSubtype
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
Parse object to JacksonJsonNode.- 参数:
obj- object- 返回:
JsonNode
-
constructJavaType
construct java type -> Jackson Java Type.- 参数:
type- java type- 返回:
- JavaType
JavaType
-