mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-18 13:10:44 +00:00
SPRINT-15: added json util helper method
This commit is contained in:
@ -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 "{"
|
** Check if a string looks like it could be a JSON object (e.g., starts with "{"
|
||||||
** (plus optional whitespace))
|
** (plus optional whitespace))
|
||||||
|
Reference in New Issue
Block a user