1

How to check if response from server is JSONAobject or JSONArray?

view story
linux-howto

http://stackoverflow.com – I have a server that returns some JSONArray by default, but when some error occurs it returns me JSONObject with error code. I'm trying to parse json and check for errors, I have piece of code that checks for error: public static boolean checkForError(String jsonResponse) { boolean status = false; try { JSONObject json = new JSONObject(jsonResponse); if (json instanceof JSONObject) { if(json.has("code")){ int code = json.optInt("code"); if(code==99){ status = true; } } (HowTos)