There is a List <Model>, which contains elements of type linkedtreemap, which in turn has a linkedtreemap$node. How do I get to a specific key and value. I get to a specific linkedTreeMap with an elementary loop, but I don't know how to get the key and value further.
for (int i=0; i < models.size(); i++){
System.out.println(models.get(i));
}
I have attached the complete code below.
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import java.util.List;
public class Main {
private final static OkHttpClient HTTP_CLIENT = new OkHttpClient();
private final static Gson GSON = new Gson();
public static void main(String[] args) throws Exception {
Request request = new Request.Builder()
.url("https://ghibliapi.herokuapp.com/films")
.get()
.build();
Response result = HTTP_CLIENT.newCall(request).execute();
List<Model> models = GSON.fromJson(result.body().charStream(), List.class);
for (int i=0; i < models.size(); i++){
System.out.println(models.get(i));
}
}
}
import java.util.List;
import lombok.Data;
@Data
class Model{
public String id;
public String title;
public String original_title;
public String original_title_romanised;
public String description;
public String director;
public String producer;
public String release_date;
public String running_time;
public String rt_score;
public List<String> people;
public List<String> species;
public List<String> locations;
public List<String> vehicles;
public String url;
}