update to not just assume object is a JSONArray, but to check it to try to avoid some type errors

This commit is contained in:
2023-03-08 16:34:31 -06:00
parent 00baf64587
commit 10afa1a80e

View File

@ -450,7 +450,20 @@ public class BaseAPIActionUtil
jsonObject = JsonUtils.toJSONObject(resultString); jsonObject = JsonUtils.toJSONObject(resultString);
if(jsonObject.has(tablePath)) if(jsonObject.has(tablePath))
{ {
resultList = jsonObject.getJSONArray(getBackendDetails(table).getTablePath()); Object o = jsonObject.get(tablePath);
if(o instanceof JSONArray jsonArray)
{
resultList = jsonArray;
}
else if(o instanceof JSONObject recordJsonObject)
{
resultList = new JSONArray();
resultList.put(recordJsonObject);
}
else
{
throw (new QException("Unrecognized object until tablePath: " + o));
}
} }
} }