I want to print my google search link to the console. For that i tried to convert the JSON to an Java Object. But i got the following result:
de.google.search.GoogleSearchJava@31ea9581
Take a look at my code:
...
URL url = new URL("https://www.googleapis.com/customsearch/v1?key="+key+ "&cx="+ cx +"&q="+ search +"&alt=json&num=1");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
System.out.println("Connection opened!");
conn.setRequestMethod("GET");
conn.setRequestProperty("Accept", "application/json");
BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream())));
GoogleSearchJava data = new Gson().fromJson(br, GoogleSearchJava.class);
// Show it.
System.out.println(data);
conn.disconnect();
...