I have gone through some of the questions here and their answers like this one which tells us how to extract a list of objects from a restTemplate response. It does not, however, solve my problem which is, I have an Entry class
@JsonIgnoreProperties(ignoreUnknown = true)
public class Entry {
private String API;
private String Description;
private String Auth;
private boolean HTTPS;
private String Cors;
private String Link;
private String Category;
// getters and setters
}
then I have an Entry implementation class which has
@JsonIgnoreProperties(ignoreUnknown = true)
public class EntryImpl {
private Long count;
private ArrayList<Entry> entries;
public EntryImpl () {
}
// getters and setters
}
and here is my request implementation to consume this api
public class RestConsump {
public static void main (String [] args) {
RestTemplate restTemplate = new RestTemplate();
String url = "https://api.publicapis.org/entries";
EntryImpl entries = restTemplate.getForObject(url, EntryImpl.class);
System.out.println(entries.getEntries().get(0)); // returns null for all entries
System.out.println(entries.getCount()); // prints the numbers of entries
}
}
My question is, how do I implement it so that EntryImpl returns the list of entries and the count.