I'm using TheMovieDB API in my assignment work for University and I'm having difficulty understanding how to access values from its nested JSON file format.
The following is a link to the file I am trying to use: https://api.themoviedb.org/3/discover/movie?api_key=822b6a3af922b0c70d5455e2d2e0f782&language=en-US&sort_by=popularity.desc&include_adult=false&include_video=true&page=1
Currently, my code looks like this:
httpConnect jParser = new httpConnect();
String json = jParser.getJSONFromUrl(url);
jsonData = json.toString();
JSONObject json1obj = new JSONObject(json);
JSONArray json1arr = json1obj.getJSONArray("results");
String jsonResults = json1arr.toString();
JSONObject first = new JSONArray(jsonResults).getJSONObject(0);
JSONArray second = first.getJSONArray("poster_path");
String secondString = second.toString();
poster_path = secondString.toString();
I am able to access the first layer ("results") but I'm having trouble going any deeper than that. The overall goal is to access the "poster_path" object. I'm new to Java and JSON so this may seem like a silly question. Any help is appreciated :)