Package rs.jackson
Class JsonUtils
java.lang.Object
rs.jackson.JsonUtils
JSON utils for mapping back and forth
- Author:
- ralph
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TConvert from JSON to Object.static <T> TConvert from JSON to Object.static <T> TConvert from JSON to Object.static <T> TfromJson(InputStream stream, com.fasterxml.jackson.core.type.TypeReference<T> type) Convert from JSON to Object.static <T> TfromJson(InputStream stream, com.fasterxml.jackson.databind.JavaType type) Convert from JSON to Object.static <T> TfromJson(InputStream stream, Class<T> clazz) Convert from JSON to Object.static <T> TConvert from JSON to Object.static <T> TConvert from JSON to Object.static <T> TConvert from JSON to Object.static <T> TConvert from JSON to Object.static <T> TConvert from JSON to Object.static <T> TConvert from JSON to Object.static com.fasterxml.jackson.databind.ObjectMapperReturns a configured JsonMapper object.static StringConvert any object to its Json representation.
-
Constructor Details
-
JsonUtils
public JsonUtils()
-
-
Method Details
-
toJson
Convert any object to its Json representation.- Parameters:
o- - the object to convert- Returns:
- the JSON string
-
fromJson
Convert from JSON to Object.- Type Parameters:
T- Class type- Parameters:
json- JSON stringclazz- Type Class- Returns:
- the object
-
fromJson
Convert from JSON to Object.- Type Parameters:
T- Class type- Parameters:
json- JSON stringtype- Java type- Returns:
- the object
-
fromJson
Convert from JSON to Object.- Type Parameters:
T- Class type- Parameters:
json- JSON stringtype- Type reference- Returns:
- the object
-
fromJson
Convert from JSON to Object.- Type Parameters:
T- Class type- Parameters:
file- JSON fileclazz- Type Class- Returns:
- the object
-
fromJson
Convert from JSON to Object.- Type Parameters:
T- Class type- Parameters:
file- JSON filetype- Java type- Returns:
- the object
-
fromJson
Convert from JSON to Object.- Type Parameters:
T- Class type- Parameters:
file- JSON filetype- Type reference- Returns:
- the object
-
fromJson
Convert from JSON to Object.- Type Parameters:
T- Class type- Parameters:
stream- JSON input streamclazz- Type Class- Returns:
- the object
-
fromJson
Convert from JSON to Object.- Type Parameters:
T- Class type- Parameters:
stream- JSON input streamtype- Java type- Returns:
- the object
-
fromJson
public static <T> T fromJson(InputStream stream, com.fasterxml.jackson.core.type.TypeReference<T> type) Convert from JSON to Object.- Type Parameters:
T- Class type- Parameters:
stream- JSON input streamtype- Type reference- Returns:
- the object
-
fromJson
Convert from JSON to Object.- Type Parameters:
T- Class type- Parameters:
reader- JSON readerclazz- Type Class- Returns:
- the object
-
fromJson
Convert from JSON to Object.- Type Parameters:
T- Class type- Parameters:
reader- JSON readertype- Java type- Returns:
- the object
-
fromJson
Convert from JSON to Object.- Type Parameters:
T- Class type- Parameters:
reader- JSON readertype- Type reference- Returns:
- the object
-
getJsonMapper
public static com.fasterxml.jackson.databind.ObjectMapper getJsonMapper()Returns a configured JsonMapper object.- Returns:
- the JsonMapper
-