public final class JsonUtil extends Object
Modifier and Type | Method and Description |
---|---|
static <T> T |
readObject(InputStream jsonStream,
Class<T> objectClass)
Deserialize json stream to object
|
static <T> T |
readObject(String objectText)
Deserialize json text to object
|
static <T> T |
readObject(String objectText,
Class<T> objectClass)
Deserialize json text to object
|
static <V> V[] |
toArray(String json,
Class<V> valueTypeClass) |
static <T> List<T> |
toList(String json,
Class<T> clazz)
Deserialize the given json string to a list
|
static <T> List<T> |
toList(String json,
Class<T> elementClass,
Class<?> elementGenericClass) |
static Map<String,Object> |
toMap(String json)
Deserialize the given json string to a map
|
static <K,V> Map<K,V> |
toMap(String json,
Class<K> keyTypeClass,
Class<V> valueTypeClass)
Deserialize the given json string to a map
|
public static <T> T readObject(String objectText, Class<T> objectClass) throws IOException
objectText
- objectClass
- com.fasterxml.jackson.core.JsonParseException
com.fasterxml.jackson.databind.JsonMappingException
IOException
public static <T> T readObject(InputStream jsonStream, Class<T> objectClass) throws IOException
jsonStream
- objectClass
- com.fasterxml.jackson.core.JsonParseException
com.fasterxml.jackson.databind.JsonMappingException
IOException
public static <T> T readObject(String objectText) throws IOException
objectText
- com.fasterxml.jackson.core.JsonParseException
com.fasterxml.jackson.databind.JsonMappingException
IOException
public static Map<String,Object> toMap(String json) throws IOException
json
- json textIOException
public static <K,V> Map<K,V> toMap(String json, Class<K> keyTypeClass, Class<V> valueTypeClass) throws IOException
json
- keyTypeClass
- valueTypeClass
- IOException
public static <V> V[] toArray(String json, Class<V> valueTypeClass) throws IOException
IOException
public static <T> List<T> toList(String json, Class<T> clazz) throws IOException
json
- json textIOException
public static <T> List<T> toList(String json, Class<T> elementClass, Class<?> elementGenericClass) throws IOException
IOException
Copyright © 2017. All rights reserved.