public class JsonUtils extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
protected static com.fasterxml.jackson.databind.ObjectMapper |
objectMapper
ObjectMapper
|
| 构造器和说明 |
|---|
JsonUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static <T> T |
deserialize(String value,
Class<T> clazz)
Deserialize object to string.
|
static Date |
deserializeToDate(com.fasterxml.jackson.core.JsonParser jsonParser,
DateFormat dateFormat)
Deserialize jsonParser object to Date object.
|
static <T> List<T> |
deserializeToList(String value,
Class<?> collectionClass,
Class<T> elementClasses)
Deserialize string value to List.
|
static String |
serialize(Object value)
Serialize string to object.
|
protected static final com.fasterxml.jackson.databind.ObjectMapper objectMapper
public static String serialize(Object value) throws com.fasterxml.jackson.core.JsonProcessingException
value - Object need serializecom.fasterxml.jackson.core.JsonProcessingExceptionpublic static <T> T deserialize(String value, Class<T> clazz) throws IOException
value - String need to be deserialized.clazz - Class objectTIOExceptionpublic static Date deserializeToDate(com.fasterxml.jackson.core.JsonParser jsonParser, DateFormat dateFormat) throws Exception
jsonParser - JsonParser object.dateFormat - DateFormat object.Exceptionpublic static <T> List<T> deserializeToList(String value, Class<?> collectionClass, Class<T> elementClasses) throws IOException
value - Json string value.collectionClass - Class object for collection.elementClasses - Class object for element in collection.List<T>IOException - From readValue.Copyright © 2019. All rights reserved.