I need to loop through a JSON and get the following information:
The original title, overview, release date, poster_path.
I have the following code..
@Override
protected void onPostExecute(String s) {
try {
JSONObject jsonObject = new JSONObject(result);
JSONArray jArray = jsonObject.getJSONArray("results");
JSONObject json_data = null;
for (int i = 0; i < jArray.length(); i++) {
JSONObject finalObject = jArray.getJSONObject(i);
String movie_title = finalObject.getString("title");
String releaseDate = finalObject.getString("release_date");
mMovie_title.setText(movie_title);
mReleaseDate.setText(releaseDate);
}
super.onPostExecute(s);
} catch (JSONException e) {
e.printStackTrace();
}
}
The problem with this code is that it only gets me the final movie in the array.
It does not print any other movie titles out.
What I need to do is fetch the movie titles from the JSON along with the overview, release dates & poster path.
Here is the JSON.. https://api.themoviedb.org/3/movie/top_rated?api_key=f1d314280284e94ff7d1feeed7d44fdf&language=en-US&page=1
Any help is much appreciated.