public class Jsons extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static String |
DEFAULT_DATE_FORMAT
默认日期格式
|
static String |
DEFAULT_DATE_TIME_FORMAT
默认日期时间格式
|
static String |
DEFAULT_TIME_FORMAT
默认时间格式
|
(专用程序包) static com.fasterxml.jackson.databind.ObjectMapper |
objectMapper |
| 构造器和说明 |
|---|
Jsons() |
| 限定符和类型 | 方法和说明 |
|---|---|
static <T> T |
copy(Object object,
Class<T> toClass) |
static <T> T |
copy(T object) |
static String |
defaultArrayJson(Object object) |
static String |
defaultObjectJson(Object object) |
static <T> T |
fromJson(byte[] bs,
Class<T> valueType) |
static <T> T |
fromJson(Map<String,Object> map,
Class<T> classType) |
static <T> T |
fromJson(String content,
Class<T> valueType)
反序列化对象
|
static <T> T |
fromJson(String content,
com.fasterxml.jackson.core.type.TypeReference valueTypeRef) |
static <T> List<T> |
fromJsonAsList(byte[] bs) |
static <T> List<T> |
fromJsonAsList(String content) |
static <T> List<T> |
fromJsonAsList(String content,
Class<T> elementClass)
序列化列表对象
|
static Map<String,Object> |
fromJsonAsMap(byte[] bs) |
static Map<String,Object> |
fromJsonAsMap(String content) |
static com.fasterxml.jackson.databind.ObjectMapper |
getObjectMapper() |
static com.fasterxml.jackson.databind.JsonNode |
parse(String content) |
private static <T> T |
runas(Callable<T> call) |
static byte[] |
toBytes(Object obj) |
static String |
toIndentJson(Object object) |
static String |
toJson(Object object) |
static void |
toOutputStream(Object value,
OutputStream out) |
public static <T> T fromJson(byte[] bs,
Class<T> valueType)
public static <T> T fromJson(String content, Class<T> valueType)
content - 内容valueType - 对象类型RuntimeException - 如果解析失败NullPointerException - 如果content是nullpublic static <T> T fromJson(String content, com.fasterxml.jackson.core.type.TypeReference valueTypeRef)
public static <T> List<T> fromJsonAsList(byte[] bs)
public static <T> List<T> fromJsonAsList(String content, Class<T> elementClass)
content - json字符串elementClass - 列表对象类型IOException - 解析异常public static com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
public static com.fasterxml.jackson.databind.JsonNode parse(String content) throws IOException
IOExceptionprivate static <T> T runas(Callable<T> call)
public static byte[] toBytes(Object obj) throws IOException
IOExceptionpublic static <T> T copy(T object)
public static void toOutputStream(Object value, OutputStream out) throws IOException
IOExceptionCopyright © 2020. All rights reserved.