0

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();           
  ...
user3541032
  • 127
  • 1
  • 1
  • 11
  • 1
    Please look at [How do I print my Java object without getting “SomeType@2f92e0f4”?](http://stackoverflow.com/questions/29140402/how-do-i-print-my-java-object-without-getting-sometype2f92e0f4) – Hovercraft Full Of Eels Jun 25 '17 at 13:52
  • Strange though, this class should implement a `toString` method by default. – cs95 Jun 25 '17 at 13:53
  • What is this library? `de.google.search.GoogleSearchJava` ? – qlown Jun 25 '17 at 14:00

0 Answers0