RM-2890 - updated json structure

This commit is contained in:
Ana Bozianu
2016-07-05 17:58:31 +03:00
parent b73fa7d7aa
commit 83fa0fec11

View File

@@ -400,4 +400,30 @@ public final class WebScriptUtils
final int status = e.getStatus();
return status >= lowerLimitInclusive && status < upperLimitExclusive;
}
/**
* Gets the {@link JSONObject} value of a given key from a json object
*
* @param jsonObject The json object
* @param key The key
* @return The {@link JSONObject} value of the given key from the json object
*/
public static JSONObject getValueFromJSONObject(JSONObject jsonObject, String key)
{
mandatory("jsonObject", jsonObject);
mandatoryString("key", key);
JSONObject value = null;
try
{
value = jsonObject.getJSONObject(key);
}
catch (JSONException error)
{
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not get value for the key '" + key + "'.", error);
}
return value;
}
}