Значение org.jsonexception типа org.jsonobject не может быть преобразовано в jsonarray

exception : org.json.JSONException: Value{"id":"6","assignment":";Array","rollno":",Array","subject":"TE_DBMS_PRAC","late":";Array"} of type org.json.JSONObject cannot be coverted to JSONArray

мой код Android

try {
JSONArray jsonArray=new JSONArray(result);
//arrayList.clear();
for(int i=0;i<jsonArray.length();i++){
JSONObject jsonObject=null;
jsonObject=jsonArray.getJSONObject(i);
rolno = jsonObject.getString("rollno");
assign=jsonObject.getString("assignment");
late=jsonObject.getString("late");
Toast.makeText(getApplicationContext(),"return",Toast.LENGTH_SHORT).show();
if(rolno.contains(rollno.getText().toString()))
{
String[] rrno = rolno.split(",");
String[] assignm=assign.split(";");
String[] lates=late.split(";");
Toast.makeText(getApplicationContext(),"roll on are"+rrno[1]+"and assign are"+assignm[1],Toast.LENGTH_SHORT).show();
for(int j=0;j<rrno.length;i++){
if(rollno.getText().toString().equals(rrno[j])){
String current_assign=assignm[j];
String current_late=lates[j];
String[] current_a_splitted=current_assign.split(",");

String[] current_l_splitted=current_late.split(",");
for(int k=0;k<current_a_splitted.length;k++){

if (Integer.parseInt(current_a_splitted[k]) == 1)
asg1.setChecked(true);
else if (Integer.parseInt(current_a_splitted[k]) == 2)
asg2.setChecked(true);
else if (Integer.parseInt(current_a_splitted[k]) == 3)
asg3.setChecked(true);
else if (Integer.parseInt(current_a_splitted[k]) == 4)
asg4.setChecked(true);
else if (Integer.parseInt(current_a_splitted[k]) == 5)
asg5.setChecked(true);
else if (Integer.parseInt(current_l_splitted[k]) == 1)
late1.setChecked(true);
else if (Integer.parseInt(current_l_splitted[k]) == 2)
late2.setChecked(true);
else if (Integer.parseInt(current_l_splitted[k]) == 3)
late3.setChecked(true);
else if (Integer.parseInt(current_l_splitted[k]) == 4)
late4.setChecked(true);
else if (Integer.parseInt(current_l_splitted[k]) == 5)
late5.setChecked(true);
}
}
}
}
// listView.setAdapter(arrayAdapter);
} catch (Exception e) {
Toast.makeText(getApplicationContext(),e.toString(),Toast.LENGTH_LONG).show();
}
}

0

Решение

Само исключение объясняет вас. Ваш результат JsonObject и не JsonArray

Попробуйте конвертировать его, используя

JSONObject jsonObject=new JSONObject(result);

и обрабатывать остальную часть кода соответственно

0

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector