このサイトから今後の映画とその要約されたキャストを返す簡単なアプリを開発しようとしています: http://developer.rottentomatoes.com/docs/read/json/v10/Upcoming_Movies . ただし、要約されたキャストと一緒に最新の映画にアクセスする方法がわかりません。JSONは私にとって少し混乱しているので、誰かがここで私を助けてくれれば幸いです。
JSON APIを使用してRotten Tomatoesから映画データをリクエストする方法を使用しましたか? これまでのところ私を助けるために、映画とキャストを「二日酔い:ブラッドリー・クーパーなど...」の形式でリストできるようにしたい.
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!");
}
}