Если ответ на запрос является ответом json, как его обработать и декодировать. Я попытался выполнить следующее и получить ошибку @ JSONArray json = new JSONArray (r1);
HttpPost post = new HttpPost(postURL);
MultipartEntity reqEntity = new MultipartEntity();
HttpResponse response = client.execute(post);
HttpEntity resEntity = response.getEntity();
String r1 = EntityUtils.toString(resEntity);
System.out.println("printing response now "+r1);
JSONArray json = new JSONArray(r1);
//Toast.makeText(getApplicationContext(), "data received"+r1, Toast.LENGTH_LONG).show();
// JSONObject json = new JSONObject(r1);
JSONArray venues = json.getJSONObject("data")
.getJSONArray("url")
.getJSONObject(0)
.getJSONArray("url");
Структура Json приведена ниже
[
{"data":
{"url":
{
"url": "http://www.xxxxxx.com/story.html", "title":"some data","source_url": "www.somesite.com", "summary": "\n \n \n \n \n somedata again"
}
}
}
]
Ошибка:
08-18 16:30:22.907: INFO/System.out(1178): Exceptionorg.json.JSONException: Value <!DOCTYPE of type java.lang.String cannot be converted to JSONArray