2016-09-06 2 views
0

JSON에서 값을 검색하려고하는데 responseString이 비어 있습니다. 여기org.json.JSONException : 안드로이드의 문자 0에서 입력 끝

다음
HttpClient httpClient = new DefaultHttpClient(); 
HttpContext httpContext = new BasicHttpContext(); 
HttpPost httpPost = new HttpPost(URL); 
String jsons = ""; 
JSONObject jsonObject = new JSONObject(); 
jsonObject.put("tbl_id", tableid); 
jsonObject.put("imei_no", phneimeino); 
jsonObject.put("server_id", usrid); 
jsonObject.put("customers", customerName1 + "," + customerName2 + "," + customerName3); 
Log.w("JSON OBJECT is ", jsonObject.toString()); 
jsons = jsonObject.toString(); 
StringEntity se = new StringEntity(jsons); 
httpPost.setEntity(se); 
httpPost.setHeader("Accept", "application/json"); 
httpPost.setHeader("Content-type", "application/json"); 
HttpResponse response = httpClient.execute(httpPost, httpContext); 
HttpEntity entity = response.getEntity(); 
String responseString = EntityUtils.toString(entity); 
Log.i("Response", responseString); 
JSONObject json = new JSONObject(responseString); 
success = json.getString("iserror"); 

responseString 내 코드 비어이며, 당신은 아마 빈 반응을 얻고있다

org.json.JSONException: End of input at character 0 of 
+1

응답 서비스 방법은 get 또는 post 방법입니까? 서비스를 확인하십시오. – prakash

+2

'responseString'을 출력하고 그것이 유효한지 확인하십시오 json –

+0

I 응답 된 문자열을 인쇄했으나 비어 있습니다 –

답변

1

으로 예외를 보여주는. 그것의 null이 아니지만 응답은 비어 있습니다. 따라서 Nullpointer 예외가 아닌이 오류가 발생합니다. 백엔드 개발자

+1

백엔드 (CMS) 측의 문제 –

1

responseString와

확인 그래서 당신은 할 수없는, 비어 : 성공 = json.getString를 ("ISERROR"); httpPost 및 서비스를 확인하십시오.

관련 문제