public class JsonUtils extends Object
| Constructor and Description |
|---|
JsonUtils() |
| Modifier and Type | Method and Description |
|---|---|
static List<Object> |
classpathToList(String classPath) |
static Map<String,Object> |
classpathToMap(String classPath) |
static Object |
classpathToObject(String classPath) |
static <T> T |
classpathToType(String classPath,
Class<T> aClass) |
static <T> T |
classpathToType(String classPath,
com.fasterxml.jackson.core.type.TypeReference<T> typeRef) |
static Object |
cloneJson(Object obj)
Makes a deep copy of a Map
|
static JsonUtil |
customJsonUtil(com.fasterxml.jackson.databind.ObjectMapper mapper)
Construct a JsonUtil with a Jackson ObjectMapper that has been preconfigured with custom
Modules or Mixins.
|
static List<Object> |
filepathToList(String filePath) |
static Map<String,Object> |
filepathToMap(String filePath) |
static Object |
filepathToObject(String filePath) |
static <T> T |
fileToType(String filePath,
Class<T> aClass) |
static <T> T |
fileToType(String filePath,
com.fasterxml.jackson.core.type.TypeReference<T> typeRef) |
static JsonUtil |
getDefaultJsonUtil() |
static Map<String,Object> |
javason(String javason)
Utility for test classes, so that they can inline json in a test class.
|
static <T> T |
jsonTo(InputStream in,
com.fasterxml.jackson.core.type.TypeReference<T> typeRef)
Deprecated.
|
static <T> T |
jsonTo(String json,
com.fasterxml.jackson.core.type.TypeReference<T> typeRef)
Deprecated.
|
static List<Object> |
jsonToList(InputStream in) |
static List<Object> |
jsonToList(String json) |
static List<Object> |
jsonToList(String json,
String charset) |
static Map<String,Object> |
jsonToMap(InputStream in) |
static Map<String,Object> |
jsonToMap(String json) |
static Map<String,Object> |
jsonToMap(String json,
String charset) |
static Object |
jsonToObject(InputStream in) |
static Object |
jsonToObject(String json) |
static Object |
jsonToObject(String json,
String charset) |
static <T> T |
navigate(Object source,
Object... paths)
Deprecated.
|
static void |
removeRecursive(Object json,
String keyToRemove)
Deprecated.
|
static <T> T |
streamToType(InputStream in,
Class<T> aClass) |
static <T> T |
streamToType(InputStream in,
com.fasterxml.jackson.core.type.TypeReference<T> typeRef) |
static <T> T |
stringToType(String json,
Class<T> aClass) |
static <T> T |
stringToType(String json,
com.fasterxml.jackson.core.type.TypeReference<T> typeRef) |
static String |
toJsonString(Object obj) |
static String |
toPrettyJsonString(Object obj) |
public static JsonUtil customJsonUtil(com.fasterxml.jackson.databind.ObjectMapper mapper)
@Deprecated 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 Map<String,Object> javason(String javason)
javason - JSON-ish string you want to turn into Maps-of-Mapspublic static JsonUtil getDefaultJsonUtil()
public static Object jsonToObject(InputStream in)
public static Map<String,Object> jsonToMap(InputStream in)
public static List<Object> jsonToList(InputStream in)
public static <T> T classpathToType(String classPath, com.fasterxml.jackson.core.type.TypeReference<T> typeRef)
public static <T> T stringToType(String json, com.fasterxml.jackson.core.type.TypeReference<T> typeRef)
public static <T> T fileToType(String filePath, com.fasterxml.jackson.core.type.TypeReference<T> typeRef)
public static <T> T streamToType(InputStream in, com.fasterxml.jackson.core.type.TypeReference<T> typeRef)
public static <T> T streamToType(InputStream in, Class<T> aClass)
@Deprecated public static <T> T jsonTo(String json, com.fasterxml.jackson.core.type.TypeReference<T> typeRef)
@Deprecated public static <T> T jsonTo(InputStream in, com.fasterxml.jackson.core.type.TypeReference<T> typeRef)
public static Object cloneJson(Object obj)
obj - object tree to copy@Deprecated public static <T> T navigate(Object source, Object... paths) throws NullPointerException, UnsupportedOperationException
source - the source json objectpaths - the paths array to travelNullPointerException - if the source is nullUnsupportedOperationException - if the source is not Map or ListCopyright © 2023. All rights reserved.