public class JsonUtils extends Object
| 构造器和说明 |
|---|
JsonUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static <T> T |
parse(com.fasterxml.jackson.databind.JsonNode jsonNode,
Class<T> valueType)
Parse the JsonNode into an object of the specified type.
|
static <T> T |
parse(String content,
Class<T> valueType)
Parse the json string into an object of the specified type.
|
static <T> List<T> |
parseArray(String content,
Class<T> valueType)
Convert json
content into a collection of required objects |
static void |
setMapper(com.fasterxml.jackson.databind.ObjectMapper mapper)
Replace the default
mapper. |
static com.fasterxml.jackson.databind.JsonNode |
toJsonNode(String json)
Parses the specified JSON string to a JsonNode
|
static <T> String |
toJsonPrettyString(T obj)
Object to json string and format and beautify
|
static String |
toJsonString(Object object)
Serializes the specified object to Json text.
|
public static void setMapper(com.fasterxml.jackson.databind.ObjectMapper mapper)
mapper.mapper - ObjectMapperpublic static <T> String toJsonPrettyString(T obj)
obj - the object for which Json representation is to be created setting for Gsonpublic static com.fasterxml.jackson.databind.JsonNode toJsonNode(String json)
json - JSON content to parse to build the JSON tree.public static String toJsonString(Object object)
object - the object for which Json representation is to be created setting for Gsonpublic static <T> T parse(com.fasterxml.jackson.databind.JsonNode jsonNode,
Class<T> valueType)
T - the type of the desired objectjsonNode - the JsonNode objectvalueType - the class of the desired objectpublic static <T> T parse(String content, Class<T> valueType)
T - the type of the desired objectcontent - the json stringvalueType - the class of the desired objectCopyright © 2023. All rights reserved.