2013-06-05 8 views
0

없음 값JSON 오류 org.json.JSONException : "org.json.JSONException : tableData 없음 값"그것은 나에게 오류 로그 제공

try { 
    JSONObject mainJson22 = new JSONObject(reply); 

    JSONObject jsonResult = mainJson22.getJSONObject("UserListByBusinessAreaContextResult"); 
    JSONArray jsonArray22 = jsonResult.getJSONArray("tableData"); 

// JSONArray jsonArray22 = mainJson22.getJSONArray("UserListByBusinessAreaContextResult"); // JSONArray jsonArray22 = jsonResult.getJSONArray("tableData"); Log.i("mainjson234","" + jsonArray22); 


    for (int i2 = 0; i2 < jsonArray22.length(); i2++) { 

     JSONObject objJson22 = jsonArray22.getJSONObject(i2); 

오류가 라인에` "JSONArray jsonArray22 = jsonResult.getJSONArray ("tableData"); "

을 heres JSON :

{ 
    "UserListByBusinessAreaContextResult": "{\"tableData\":[{\"UserID\":30,\"Username\":\"Teste\",\"Name\":\"Teste\"}]}" 
} 
+0

'UserListByBusinessAreaContextResult' 값은 JSON입니다. 즉 JSON이 두 번 인코딩됩니다. – Musa

+0

그게 무슨 뜻입니까? –

+0

json을 생성 했습니까? – Musa

답변

0

개체 UserListByBusinessAreaContextResult 문자열이 포함되어 있습니다. 이 문자열은 다음과 같습니다.

따옴표가 있습니까? 문제는 WCF 서비스가 객체가 아닌 JSON 문자열을 반환한다는 것입니다. 따라서 WCF 서비스를 변경하여 객체를 전달하거나 문자열을 다시 구문 분석해야합니다. 이렇게 (테스트되지 않음) :

JSONObject mainJson22 = new JSONObject(reply); 
JSONObject tableData = new JSONObject(
     mainJson22.getString("UserListByBusinessAreaContextResult")); 
관련 문제