내 서비스 웹을 호출 할 때이 예외가 있습니다. org.json.JSONArray 유형의 org.json.JSONException : Value [{}]는 JSONObject로 변환 할 수 없습니다.
이것은 내 소스 코드입니다.
JsonObjectRequest obreq = new JsonObjectRequest(Request.Method.GET, url + editText.getText().toString(), null,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
try {
JSONArray missions = response.getJSONArray("Value");
for(int i=0;i<missions.length();i++){
// Get current json object
JSONObject mission = missions.getJSONObject(i);
// Get the current student (json object) data
Long idMission = mission.getLong("idMission");
String etatMission = mission.getString("etatMission");
text.append(idMission+" " + etatMission);
text.append("\n\n");
}
}catch (JSONException e) {
e.printStackTrace();
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
text.setText(error.getMessage());
}
}
);
requestQueue.add(obreq);
ansewer는 매우 간단합니다.
for(int i=0;i<response.length();i++){
JSONObject mission = response.getJSONObject(i);
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다