[{ "data": { "statues": "2"}}] 인 로컬 호스트의 데이터를 구문 분석하려고합니다.localhost에서 JSON을 구문 분석하는 방법은 무엇입니까?
이것은 JSON 내 코드입니다 :
JSONArray jArray = new JSONArray(result);
for(int i=0;i<jArray.length();i++){
JSONObject json_data = jArray.getJSONObject(i);
Log.i("log_tag","statues: "+json_data.getString("statues"));
//Get an output to the screen
returnString = json_data.getString("statues");
tv.setText(returnString);
모든 것이 좋아 보이지만, 내 로그 고양이,이 오류가 발생합니다
11-15 09:07:27.403: E/log_tag(3037): Error in http connection!!org.json.JSONException: Value [{"data":{"statues":"2"}}] of type org.json.JSONArray cannot be converted to JSONObject
내가이 상을 잡는다 때문에 괜찮 소리라고 , 그 값 (2)은 아닙니다. json_data.getInt("statues");
도 시도했지만 문제는 여전히 동일합니다.
어떻게해야합니까?!
터져 죽자을 사용할 수 있습니다 자세한 내용은이
같은
JSONObject
를 얻을 수있다! 그것은 효과가 있었다. 고마워요 – Sean@Shawn 도움이 된 것을 기쁘게 생각합니다. – Hariharan