类 JsonUtils
- java.lang.Object
-
- com.baidubce.util.JsonUtils
-
public class JsonUtils extends Object
JsonUtils for Serialization and deserialization of JSON
-
-
构造器概要
构造器 构造器 说明 JsonUtils()
-
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static <T> TfromJsonString(String json, Class<T> clazz)Returns the deserialized object from the given json string and target class; or null if the given json string is null.static com.fasterxml.jackson.databind.ObjectMappergetObjectMapper()static com.fasterxml.jackson.databind.ObjectWritergetPrettywriter()static com.fasterxml.jackson.databind.ObjectWritergetWriter()static com.fasterxml.jackson.core.JsonGeneratorjsonGeneratorOf(Writer writer)static com.fasterxml.jackson.databind.JsonNodejsonNodeOf(String json)static voidload(InputStream input, Object obj)static <T> TloadFrom(File file, Class<T> clazz)static <T> TloadFrom(InputStream input, Class<T> clazz)static StringtoJsonPrettyString(Object value)static StringtoJsonString(Object value)static StringtoJsonStringWithRootName(Object value)Serialization of object
-
-
-
方法详细资料
-
toJsonPrettyString
public static String toJsonPrettyString(Object value) throws com.fasterxml.jackson.core.JsonProcessingException
- 抛出:
com.fasterxml.jackson.core.JsonProcessingException
-
toJsonStringWithRootName
public static String toJsonStringWithRootName(Object value)
Serialization of object- 参数:
value- the object need Serialize- 返回:
- json string include object name
-
fromJsonString
public static <T> T fromJsonString(String json, Class<T> clazz)
Returns the deserialized object from the given json string and target class; or null if the given json string is null.
-
jsonNodeOf
public static com.fasterxml.jackson.databind.JsonNode jsonNodeOf(String json)
-
jsonGeneratorOf
public static com.fasterxml.jackson.core.JsonGenerator jsonGeneratorOf(Writer writer) throws IOException
- 抛出:
IOException
-
loadFrom
public static <T> T loadFrom(File file, Class<T> clazz) throws IOException
- 抛出:
IOException
-
load
public static void load(InputStream input, Object obj) throws IOException, com.fasterxml.jackson.core.JsonProcessingException
- 抛出:
IOExceptioncom.fasterxml.jackson.core.JsonProcessingException
-
loadFrom
public static <T> T loadFrom(InputStream input, Class<T> clazz) throws com.fasterxml.jackson.core.JsonParseException, com.fasterxml.jackson.databind.JsonMappingException, IOException
- 抛出:
com.fasterxml.jackson.core.JsonParseExceptioncom.fasterxml.jackson.databind.JsonMappingExceptionIOException
-
getObjectMapper
public static com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
-
getWriter
public static com.fasterxml.jackson.databind.ObjectWriter getWriter()
-
getPrettywriter
public static com.fasterxml.jackson.databind.ObjectWriter getPrettywriter()
-
-