SPRINT-15: added json util helper method

This commit is contained in:
Tim Chamberlain
2022-11-10 13:21:11 -06:00
parent 6496986aab
commit 6d08afa4c2

View File

@ -203,6 +203,27 @@ public class JsonUtils
/*******************************************************************************
** returns a JSONArray with a single value if given value looks like an object
** otherwise returns the JSONArray
**
*******************************************************************************/
public static JSONArray getJSONArrayFromJSONObjectOrJSONArray(Object o)
{
JSONArray a = new JSONArray();
if(o instanceof JSONObject)
{
a.put(o);
}
else
{
a = (JSONArray) o;
}
return (a);
}
/*******************************************************************************
** Check if a string looks like it could be a JSON object (e.g., starts with "{"
** (plus optional whitespace))