com.bazaarvoice.jolt.utils
public class JoltUtils extends Object
| Constructor and Description |
|---|
JoltUtils() |
| Modifier and Type | Method and Description |
|---|---|
static <T> T |
cast(Object object)
Type casts an input object to class indicated by TypeToken
|
static <E> E[] |
cast(Object[] object)
Type cast to array E[]
|
static boolean |
isEmptyJson(Object obj)
Given a json document, checks if it has any "leaf" values, can handle deep nesting of lists and maps
i.e.
|
static List<Object[]> |
listKeyChains(Object source)
Given a json document, finds out absolute path to every leaf element
i.e.
|
static List<Object[]> |
listKeyChains(Object key,
Object value)
Helper/overridden method for listKeyChain(source), it accepts a key-value pair for convenience
note: "key": value (an item in map) and [value] (an item in list) is generalized here
as [value] is interpreted in json path as 1: value
|
static <T> T |
navigate(Object source,
Object... paths)
Navigate inside a json object in quick and dirty way.
|
static <T> T |
navigateSafe(T defaultValue,
Object source,
Object... paths)
Navigate inside a json object in quick and "dirtier" way, i.e.
|
static void |
removeRecursive(Object json,
String keyToRemove)
Removes a key recursively from anywhere in a JSON document.
|
static String |
toSimpleTraversrPath(Object[] paths)
Converts a standard json path to human readable SimpleTraversr compatible path
|
public static void removeRecursive(Object json, String keyToRemove)
json - the Jackson Object version of the JSON document
(contents changed by this call)keyToRemove - the key to remove from the documentpublic static <T> T navigate(Object source, Object... paths)
source - the source json objectpaths - the paths array to travelNullPointerException - if the source is nullUnsupportedOperationException - if the source is not Map or Listpublic static <T> T navigateSafe(T defaultValue,
Object source,
Object... paths)
source - the sourcepaths - the paths arrayUnsupportedOperationException - the unsupported operation exceptionpublic static boolean isEmptyJson(Object obj)
obj - sourcepublic static List<Object[]> listKeyChains(Object source)
source - jsonpublic static List<Object[]> listKeyChains(Object key, Object value)
key - value - public static String toSimpleTraversrPath(Object[] paths)
paths - the path array of objectspublic static <T> T cast(Object object)
object - the input object to castpublic static <E> E[] cast(Object[] object)
object - the input object to castCopyright © 2014. All Rights Reserved.