Я получаю ответ json на стороне сервера, чтобы загрузить мое меню, я дважды пробовал, и он дал это сообщение об ошибке (данные анализа ошибок org.json.JSONException).Получение частичного ответа от Json
Причина в том, что я получаю ответ частично, в обеих попытках я получил разные ответы, как показано на изображениях. я думаю, что я не получаю полный ответ json, получая только частичный ответ. что я должен сделать, чтобы получить полный ответ.
это мой код
@Override
protected JSONObject doInBackground(String... params) {
String path = null;
String response = null;
HashMap<String, String> request = null;
JSONObject requestJson = null;
DefaultHttpClient httpClient = null;
HttpPost httpPost = null;
StringEntity requestString = null;
ResponseHandler<String> responseHandler = null;
// get the email and password
try {
path = "http://xxxxxxxxxxxxxxxxxxx";
new URL(path);
} catch (MalformedURLException e) {
e.printStackTrace();
}
try {
// set the API request
request = new HashMap<String, String>();
request.put(new String("CetegoryCode"), "P");
request.entrySet().iterator();
// Store locations in JSON
requestJson = new JSONObject(request);
httpClient = new DefaultHttpClient();
httpPost = new HttpPost(path);
requestString = new StringEntity(requestJson.toString());
// sets the post request as the resulting string
httpPost.setEntity(requestString);
httpPost.setHeader("Content-type", "application/json");
// Handles the response
responseHandler = new BasicResponseHandler();
response = httpClient.execute(httpPost, responseHandler);
responseJson = new JSONObject(response);
} catch (Exception e) {
Log.e("Buffer Error", "Error converting result " + e.toString());
}
try {
responseJson = new JSONObject(response);
} catch (JSONException e) {
Log.e("JSON Parser", "Error parsing data " + e.toString());
}
return responseJson;
}
это изображение
ответ, который у получает от вашего АФИ возвращающегося JSONObject или JsonArray? – user1140237
JsonArray >> ответ начинается следующим образом: Value [{"ItemCode": "ABCD", "IsMayoBaseAvailable": false, –
Вы получаете ответ в ответ Json = new JSONObject (response); ? – user1140237