Class JsonUtils
java.lang.Object
com.bazaarvoice.jolt.JsonUtils
Static method convenience wrappers for a JsonUtil configured with a minimal ObjectMapper.
The ObjectMapper use is configured to :
Allow comments in the JSON strings,
Hydrates all JSON Maps into LinkedHashMaps.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclasspathToList(String classPath) classpathToMap(String classPath) static ObjectclasspathToObject(String classPath) static <T> TclasspathToType(String classPath, com.fasterxml.jackson.core.type.TypeReference<T> typeRef) static <T> TclasspathToType(String classPath, Class<T> aClass) static ObjectMakes a deep copy of a Mapinvalid input: '<'String, Object> object by converting it to a String and then back onto stock JSON objects.static JsonUtilcustomJsonUtil(com.fasterxml.jackson.databind.ObjectMapper mapper) Construct a JsonUtil with a Jackson ObjectMapper that has been preconfigured with custom Modules or Mixins.filepathToList(String filePath) filepathToMap(String filePath) static ObjectfilepathToObject(String filePath) static <T> TfileToType(String filePath, com.fasterxml.jackson.core.type.TypeReference<T> typeRef) static <T> TfileToType(String filePath, Class<T> aClass) static JsonUtilUtility for test classes, so that they can inline json in a test class.static <T> TjsonTo(InputStream in, com.fasterxml.jackson.core.type.TypeReference<T> typeRef) Deprecated.static <T> TDeprecated.jsonToList(String json) jsonToList(String json, String charset) jsonToMap(InputStream in) static Objectstatic ObjectjsonToObject(String json) / All the methods listed below are static passthrus to the JsonUtil interfacestatic ObjectjsonToObject(String json, String charset) static <T> TDeprecated.static voidremoveRecursive(Object json, String keyToRemove) Deprecated.static <T> TstreamToType(InputStream in, com.fasterxml.jackson.core.type.TypeReference<T> typeRef) static <T> TstreamToType(InputStream in, Class<T> aClass) static <T> TstringToType(String json, com.fasterxml.jackson.core.type.TypeReference<T> typeRef) static <T> TstringToType(String json, Class<T> aClass) static StringtoJsonString(Object obj) static StringtoPrettyJsonString(Object obj)
-
Field Details
-
util
-
-
Constructor Details
-
JsonUtils
public JsonUtils()
-
-
Method Details
-
customJsonUtil
Construct a JsonUtil with a Jackson ObjectMapper that has been preconfigured with custom Modules or Mixins. -
removeRecursive
Deprecated.Removes a key recursively from anywhere in a JSON document. NOTE: mutates its input. Deprecated: use JoltUtils instead- Parameters:
json- the Jackson Object version of the JSON document (contents changed by this call)keyToRemove- the key to remove from the document
-
javason
Utility for test classes, so that they can inline json in a test class. Does a character level replacement of apostrophe (') with double quote ("). This means you can express a snippit of JSON without having to forward slash escape everything. This is character based, so don't have any apostrophes (') in your test data.- Parameters:
javason- JSON-ish string you want to turn into Maps-of-Maps- Returns:
- Maps-of-Maps
-
getDefaultJsonUtil
-
jsonToObject
-
jsonToObject
-
jsonToObject
-
jsonToMap
-
jsonToMap
-
jsonToMap
-
jsonToList
-
jsonToList
-
jsonToList
-
filepathToObject
-
filepathToMap
-
filepathToList
-
classpathToObject
-
classpathToMap
-
classpathToList
-
classpathToType
public static <T> T classpathToType(String classPath, com.fasterxml.jackson.core.type.TypeReference<T> typeRef) -
classpathToType
-
stringToType
public static <T> T stringToType(String json, com.fasterxml.jackson.core.type.TypeReference<T> typeRef) -
stringToType
-
fileToType
public static <T> T fileToType(String filePath, com.fasterxml.jackson.core.type.TypeReference<T> typeRef) -
fileToType
-
streamToType
public static <T> T streamToType(InputStream in, com.fasterxml.jackson.core.type.TypeReference<T> typeRef) -
streamToType
-
jsonTo
@Deprecated public static <T> T jsonTo(String json, com.fasterxml.jackson.core.type.TypeReference<T> typeRef) Deprecated.Use the stringToType method instead. -
jsonTo
@Deprecated public static <T> T jsonTo(InputStream in, com.fasterxml.jackson.core.type.TypeReference<T> typeRef) Deprecated.Use the streamToType method instead. -
toJsonString
-
toPrettyJsonString
-
cloneJson
-