public class JsonUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static com.jayway.jsonpath.JsonPath |
compileJsonPath(String jsonPath)
Compiles the given JSONPath.
|
static List<Object> |
convertJSONArrayToList(org.codehaus.jettison.json.JSONArray jsonArray)
Converts a JSONArray into a Java-standard List
|
static org.codehaus.jettison.json.JSONArray |
convertToJSONArray(Object inputObject)
Converts an Object to JSONArray
|
static org.codehaus.jettison.json.JSONObject |
convertToJSONObject(Object inputObject)
Converts an Object to JSONObject
|
static boolean |
isEmpty(Object object) |
static Object |
readJsonPath(org.codehaus.jettison.json.JSONObject json,
String jsonPath)
Gets a value that matches the given JSONPath.
|
static Object |
readJsonPath(org.codehaus.jettison.json.JSONObject json,
String jsonPath,
boolean extractSingleElement)
Gets a value that matches the given JSONPath.
|
public static boolean isEmpty(Object object)
object - the Object to be validatedtrue if the Object is null or emptypublic static com.jayway.jsonpath.JsonPath compileJsonPath(String jsonPath)
jsonPath - the JSONPath to be validatedJsonPath objectpublic static Object readJsonPath(org.codehaus.jettison.json.JSONObject json, String jsonPath)
json - a JSON object input datajsonPath - the JSONPath to be evaluatednull if no match
was found. If the JSON is empty or null, the same object will be returned.public static Object readJsonPath(org.codehaus.jettison.json.JSONObject json, String jsonPath, boolean extractSingleElement)
jsonPath - the JSONPath to be validatedjson - a JSON object input dataextractSingleElement - a flag indicating whether the method should return the
single value of a JSONArray instead of the array itself,
provided that the length of the returnable array is equal
to one.jsonpath over the json object;public static org.codehaus.jettison.json.JSONObject convertToJSONObject(Object inputObject) throws org.codehaus.jettison.json.JSONException
inputObject - the object to be convertedorg.codehaus.jettison.json.JSONException - in case of errors converting into JSONObjectpublic static org.codehaus.jettison.json.JSONArray convertToJSONArray(Object inputObject) throws org.codehaus.jettison.json.JSONException
inputObject - the object to be convertedorg.codehaus.jettison.json.JSONException - in case of errors converting into JSONArrayCopyright © 2020. All rights reserved.