我遇到了字符串无法转换为JSONObject.Anyone的问题,可以帮助解决这个问题吗?谢谢,非常感谢你的帮助。
protected void onPostExecute(String result) {
if (result==null || result.length()==0){
// no result:
return;
}
//clear the list
moviesList.clear();
try {
//turn the result into a JSON object
JSONObject responseObject = new JSONObject("results");
// get the JSON array named "results"
JSONArray resultsArray = responseObject.getJSONArray(result);
// Iterate over the JSON array:
for (int i = 0; i < resultsArray.length(); i++) {
// the JSON object in position i
JSONObject messageObject = resultsArray.getJSONObject(i);
// get the primitive values in the object
String title = messageObject.getString("title");
String details = messageObject.getString("synopsis");
//put into the list:
Movie movie = new Movie(title, details, null,null);
moviesList.add(movie);
}
} catch (JSONException e) {
e.printStackTrace();
}
//refresh listView:
adapter.notifyDataSetChanged();
}
} 结果有价值
错误在以下行中:
JSONObject responseObject = new JSONObject("results");发布于 2013-11-13 07:23:11
String obj=JSONObject.quote(YourData);
JSONArray lArray=new JSONArray(obj);
// or simply Delete the prefix 'results' from your php Code
// $res2=array("results"=>$response);
// and you will retrive directelly your JsonArray like
JSONArray lArray=new JSONArray(YouData);https://stackoverflow.com/questions/19942016
复制相似问题