Skip to content Skip to sidebar Skip to footer

Json Object Cannot Be Converted To Jsonarray In Android

01-16 08:16:19.210: W/System.err(1394): org.json.JSONException: Value {'GetDoctorsListResult':[ {'Name':'Sujay Sharma','DoctorID':154,'Clinics':null,'speciality':'

Solution 1:

Try to replace this:

results = new JSONArray(new String(buffer));

by this:

results = new JSONObject(new String(buffer)).getJSONArray("GetDoctorsListResult");

Solution 2:

HttpEntity entity = httpResponse.getEntity(); 
String result =  EntityUtils.toString(entity);
JSONObject jsonObject=new JSONObject(result);
JSONArray jsonArray=jsonObject.getJSONArray("GetDoctorsListResult");

use this code after getting response.


Solution 3:

The root element of the JSON from URL is a JSONObject you should first parse it to JSONObject and then get GetDoctorsListResult which is an array from the object.


Solution 4:

I think your First Element of object GetDoctorsListResult is JSON array . So you have to take its value in json array.

REFER THIS THREAD and THIS ONE

JSONArray DoctorsList= jsonResponse.getJSONArray("GetDoctorsListResult");


Post a Comment for "Json Object Cannot Be Converted To Jsonarray In Android"