val jsonObject = JSONObject(response)
val jObj = jsonObject.optJSONObject("result_key")
if (jObj.get("json_key") is JSONArray){
val rejProArr: JSONArray = jObj.getJSONArray("json_key")
} else if (jObj.get("json_key") is JSONObject) {
val rejProObject: JSONObject = jObj.optJSONObject("json_key")}Here json_key either JSONArray or JSONObject, So we can parse accordingly to avoid crash.