【发布时间】:2013-06-17 01:08:40
【问题描述】:
我正在尝试开发一个快速应用程序,该应用程序将返回来自此站点的即将上映的电影及其删节演员:http://developer.rottentomatoes.com/docs/read/json/v10/Upcoming_Movies。但是,我不确定如何访问最新电影以及删减的演员阵容。如果有人可以在这里帮助我,我将不胜感激,因为 JSON 对我来说有点混乱。
到目前为止,我一直使用How to request movie data from Rotten Tomatoes using their JSON API? 来帮助我,但我希望能够以“宿醉:布拉德利库珀等...”的格式列出这部电影和演员阵容。
if (response != null)
{
try
{
// convert the String response to a JSON object,
// because JSON is the response format Rotten Tomatoes uses
JSONObject jsonResponse = new JSONObject(response);
// fetch the array of movies in the response
JSONArray movies = jsonResponse.getJSONArray("movies");
// add each movie's title to an array
String[] movieTitles = new String[movies.length()];
for (int i = 0; i < movies.length(); i++)
{
JSONObject movie = movies.getJSONObject(i);
movieTitles[i] = movie.getString("title");
JSONArray cast = movie.getJSONArray("abridged_cast");
String[] castmembers = new String[cast.length()];
for(int j =0; j<cast.length();j++){
}
}
// update the UI
refreshMoviesList(movieTitles);
}
catch (JSONException e)
{
Log.d("Test", "Failed to parse the JSON response!");
}
}
【问题讨论】:
标签: android json rotten-tomatoes