I'am fetching the data from the server and storing in my android application. I'am getting the JSONArray name as "project_data" and am having list of JSONObjects in the array. Am iterating the list of JSONObject based on the length of JSONArray.
This is the JSON data where am getting from the server
"project_data": [
null,
null,
{
"id": "14",
"name": "JOHN",
"short_name": "JH",
}
]
This is the error what am facing
value null at 0 of type org.json.jsonobject$1 cannot be converted to jsonobject
This is my code
JSONArray projectData=job.getJSONArray("project_data");
for(int i=0;i<projectData.length();i++)
{
JSONObject proj=projectData.getJSONObject(i);
Log.i("projectdetails",proj.toString());
pro = Project.getProject(getValue(proj,"id"));
if(pro==null)
pro=new Project();
pro.p_id = getValue(proj,"id");
pro.name = getValue(proj,"name");
pro.short_name = getValue(proj,"short_name");
pro.save();
}
I'am facing the error in this line. JSONObject proj=projectData.getJSONObject(i);
Please help me to solve this problem.