Package org.hisp.dhis.util
Class JacksonUtils
java.lang.Object
org.hisp.dhis.util.JacksonUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TfromJson(InputStream input, Class<T> type) Deserializes JSON from the givenInputStreaminto an object of the specified type.static <T> TDeserializes the given JSON string into an object of the specified type.static com.fasterxml.jackson.databind.ObjectMapperReturns anObjectMapper.static StringtoJsonString(Object value) Serializes the given object to JSON and returns the result as a String.
-
Constructor Details
-
JacksonUtils
public JacksonUtils()
-
-
Method Details
-
getObjectMapper
public static com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()Returns anObjectMapper.- Returns:
- an
ObjectMapper.
-
toJsonString
Serializes the given object to JSON and returns the result as a String.- Parameters:
value- the object value to serialize.- Returns:
- a JSON representation of the given object as a String.
-
fromJson
Deserializes the given JSON string into an object of the specified type.- Type Parameters:
T- the type of the object to return.- Parameters:
string- the JSON string to deserialize.type- the class of the target type.- Returns:
- an object of type T.
-
fromJson
Deserializes JSON from the givenInputStreaminto an object of the specified type.- Type Parameters:
T- the type of the object to return.- Parameters:
input- theInputStreamcontaining JSON data.type- the class of the target type.- Returns:
- an object of type T.
-