Package com.bazaarvoice.jolt
Interface JsonUtil
- All Known Implementing Classes:
JsonUtilImpl
public interface JsonUtil
Utility methods for getting JSON content loaded from
the filesystem, the classpath, or in memory Strings.
Also has methods to serialize Java object to JSON strings.
Implementations of this interface can specify their own
Jackson ObjectMapper so that Domain specific Java Objects
can successfully be serialized and de-serialized.
-
Method Summary
Modifier and TypeMethodDescriptionclasspathToList
(String classPath) classpathToMap
(String classPath) classpathToObject
(String classPath) <T> T
classpathToType
(String classPath, com.fasterxml.jackson.core.type.TypeReference<T> typeRef) <T> T
classpathToType
(String classPath, Class<T> aClass) Makes a deep copy of a Mapinvalid input: '<'String, Object> object by converting it to a String and then back onto stock JSON objects.filepathToList
(String filePath) filepathToMap
(String filePath) filepathToObject
(String filePath) <T> T
fileToType
(String filePath, com.fasterxml.jackson.core.type.TypeReference<T> typeRef) <T> T
fileToType
(String filePath, Class<T> aClass) <T> T
jsonTo
(InputStream in, com.fasterxml.jackson.core.type.TypeReference<T> typeRef) Deprecated.<T> T
Deprecated.jsonToList
(String json) jsonToList
(String json, String charset) jsonToMap
(InputStream in) jsonToObject
(String json) jsonToObject
(String json, String charset) <T> T
streamToType
(InputStream in, com.fasterxml.jackson.core.type.TypeReference<T> typeRef) <T> T
streamToType
(InputStream in, Class<T> aClass) <T> T
stringToType
(String json, com.fasterxml.jackson.core.type.TypeReference<T> typeRef) <T> T
stringToType
(String json, Class<T> aClass) toJsonString
(Object obj) toPrettyJsonString
(Object obj)
-
Method Details
-
jsonToObject
-
jsonToObject
-
jsonToObject
-
jsonToMap
-
jsonToMap
-
jsonToMap
-
jsonToList
-
jsonToList
-
jsonToList
-
filepathToObject
-
filepathToMap
-
filepathToList
-
classpathToObject
-
classpathToMap
-
classpathToList
-
jsonTo
Deprecated.Use the stringToType method instead. -
jsonTo
Deprecated.Use the streamToType method instead. -
stringToType
-
stringToType
-
classpathToType
-
classpathToType
-
fileToType
-
fileToType
-
streamToType
-
streamToType
-
toJsonString
-
toPrettyJsonString
-
cloneJson
Makes a deep copy of a Mapinvalid input: '<'String, Object> object by converting it to a String and then back onto stock JSON objects. Leverages Serialization- Parameters:
obj
- object tree to copy- Returns:
- deep copy of the incoming obj
-