저는 발리 (ballley)를 사용하고 json 파싱을 구현하고 있습니다. json 구문 분석을 수행하고 목록보기에서 데이터를 표시하고 있습니다. 나는 모든 일 (게터 세터, 싱글 톤 클래스, 어댑터 등)를 만들었다하지만 해석의 시간에 나는응답시 JSON을 구문 분석하는 방법
{
"result": [{
"id": "1",
"name": "Prabhat",
"email": "[email protected]"
}, {
"id": "2",
"name": "Apurva",
"email": "[email protected]"
}, {
"id": "3",
"name": "sunny",
"email": "[email protected]"
}, {
"id": "4",
"name": "Creation InfoTech",
"email": "[email protected]"
}, {
"id": "5",
"name": "Sanjay Mishra",
"email": "[email protected]"
}]
}
그리고 내 자바 코드가
입니다 구문 분석하는 방법을 어려움에 직면하고있다
JsonObjectRequest request = new JsonObjectRequest(url_Array, new JSONObject(), new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
for (int i = 0; i < response.length(); i++) {
try {
Log.d(TAG, "working");
JSONObject object = response.getJSONObject(i);
// Now this is my PersonInfo class in which i have define my getters and setters
PersonInfo info = new PersonInfo(object.getString("id"), object.getString("name"), object.getString("email"));
personInfos.add(info);
} catch (JSONException e) {
e.printStackTrace();
}
}
adapter.notifyDataSetChanged();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(getApplicationContext(), "Something not ok", Toast.LENGTH_SHORT).show();
}
});
AppController.getInstance(getApplicationContext()).AddtoRequestQueue(request);
}
** 구문 분석의 어려움에 직면, 친절하기 전에 **
"파싱에 직면하는 데 어려움"을 수행 할 수 있습니다. 우리가 이걸 어떻게해야 하죠? 그게 무슨 뜻 이죠? 오류가 있습니까? – rmlan
예, 응답시 오류가 발생했습니다. –
어떤 오류가 발생하거나 어떤 결과를 얻고 싶습니까? –