I finally figured out the main flaw after going through the raw JSON output. Google's JSON was returning an array of "items" instead via the []
symbols, so after adding a List in the GResults class as so:
import java.util.List;
public class GResults {
public String link;
public List<GResults> items;
public String getLink(){
return link;
}
public List<GResults> getItems(){
return items;
}
public void setLink(String link){
this.link = link;
}
public void setGroups(List<GResults> items){
this.items = items;
}
public void getThing (int i){
System.out.println(items.get(i));
}
public String toString(){
return String.format("%s", link);
}
}
I was able to return a series of links with the following command in the main GSearch class:
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.setRequestProperty("Accept","application/json");
BufferedReader br = new BufferedReader(new InputStreamReader ( ( conn.getInputStream() ) ) );
GResults results = new Gson().fromJson(br, GResults.class);
for (int i=0; i<10; i++)
results.getThing(i);