the request processing code
while($op=db_fetch_object($result))
{
$data[$i++]=array($op->name,$op->age,$op->dept);
}
echo json_encode($data);
$data contains
[["Aadidev","23","division1"],["Ragman","35","division3"],["Sahlaad","27","division1"],["Maraadhak","21","division2"],["Arya","48","division1"],["Shank","25","division1"],["Aatmaj","54","division1"],["Abhay","46","division2"],["Bhinatha","37","division2"],["Abhineet","29","division3"],["Srita","47","division1"]]
Android code
String nameop="";
try{
JSONObject json=new JSONObject(page);
JSONArray namearr=json.names();
JSONArray valarr=json.toJSONArray(namearr);
for(int i=0;i<valarr.length();i++)
{
nameop+=namearr.getString(i)+" "+valarr.getString(i)+"\n";
}
result.setText(nameop);
}catch(Exception e){
Toast.makeText(this,e.toString(), Toast.LENGTH_LONG).show();
}
which results an exception
org.json.JSONException: A JSONObject text must begin with '{' at character 1 of [["Aadidev","23","division1"],["Ragman","35","division3"],["Sahlaad","27","division1"],["Maraadhak","21","division2"],["Arya","48","division1"],["Shank","25","division1"],["Aatmaj","54","division1"],["Abhay","46","division2"],["Bhinatha","37","division2"],["Abhineet","29","division3"],["Srita","47","division1"]].