title: REST GET request doesn't show List<object> as JSON
body: <p>I am new to Spingboot, doing a demo (an example) of a very simple application to display a list of classes as a JSON, but I get an error. What did I miss in my configuration/dependencies?</p>
  
  <p>My pom.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
   &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
       &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
       &lt;parent&gt;
            &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
            &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
            &lt;version&gt;2.1.3.RELEASE&lt;/version&gt;
            &lt;relativePath/&gt; &lt;!-- lookup parent from repository --&gt;
       &lt;/parent&gt;
       &lt;groupId&gt;com.beniregev&lt;/groupId&gt;
       &lt;artifactId&gt;booking-demo&lt;/artifactId&gt;
       &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
       &lt;name&gt;booking-demo&lt;/name&gt;
       &lt;description&gt;Demo project for Spring Boot&lt;/description&gt;
  
       &lt;properties&gt;
            &lt;java.version&gt;1.8&lt;/java.version&gt;
       &lt;/properties&gt;
  
       &lt;dependencies&gt;
            &lt;dependency&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-starter-actuator&lt;/artifactId&gt;
            &lt;/dependency&gt;
            &lt;dependency&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
            &lt;/dependency&gt;
            &lt;dependency&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-starter-thymeleaf&lt;/artifactId&gt;
            &lt;/dependency&gt;
            &lt;dependency&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
            &lt;/dependency&gt;
  
            &lt;dependency&gt;
                  &lt;groupId&gt;org.hsqldb&lt;/groupId&gt;
                  &lt;artifactId&gt;hsqldb&lt;/artifactId&gt;
                  &lt;scope&gt;runtime&lt;/scope&gt;
            &lt;/dependency&gt;
            &lt;dependency&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
                  &lt;scope&gt;test&lt;/scope&gt;
            &lt;/dependency&gt;
       &lt;/dependencies&gt;
  
       &lt;build&gt;
            &lt;plugins&gt;
                  &lt;plugin&gt;
                       &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                       &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
                  &lt;/plugin&gt;
            &lt;/plugins&gt;
       &lt;/build&gt;
  
   &lt;/project&gt;
  </code></pre>
  
  <p>My directories structure:
  <a href="https://i.stack.imgur.com/VHL8E.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VHL8E.png" alt="Application Directories structure"></a></p>
  
  <p>DemoController.java - this is working ("localhost:8080/hello")</p>
  
  <pre><code>package com.beniregev.bookingdemo;
  
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RestController;
  
  @RestController
  public class DemoController {
  
      @RequestMapping("/hello")
      public String hello() {
          return "Hello";
      }
  }
  </code></pre>
  
  <p>HotelBooking.java</p>
  
  <pre><code>package com.beniregev.bookingdemo;
  
  public class HotelBooking {
      private String hotelName;
      private double pricePerNight;
      private int numberOfNights;
  
      public HotelBooking(String hotelName, double pricePerNight, int numberOfNights) {
          this.hotelName = hotelName;
          this.pricePerNight = pricePerNight;
          this.numberOfNights = numberOfNights;
      }
  
      public String getHotelName() {
          return hotelName;
      }
  
      public double getPricePerNight() {
          return pricePerNight;
      }
  
      public int getNumberOfNights() {
          return numberOfNights;
      }
  
      public double getTotalPrica() {
          return pricePerNight * numberOfNights;
      }
  }
  </code></pre>
  
  <p>BookingController.java</p>
  
  <pre><code>package com.beniregev.bookingdemo;
  
  import org.springframework.web.bind.annotation.PathVariable;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  import org.springframework.web.bind.annotation.RestController;
  
  import java.util.ArrayList;
  import java.util.List;
  import java.util.stream.Collectors;
  
  @RestController
  @RequestMapping(value="/bookings")
  public class BookingController {
      private List&lt;HotelBooking&gt; bookings;
  
      public BookingController() {
          bookings = new ArrayList&lt;&gt;();
  
          bookings.add(new HotelBooking("Marriot", 200.50, 3));
          bookings.add(new HotelBooking("Novotel", 140.74, 1));
          bookings.add(new HotelBooking("Ibis", 90.0, 4));
          bookings.add(new HotelBooking("Hilton", 150.60, 5));
      }
  
      @RequestMapping(value = "/all", method = RequestMethod.GET)
      public List&lt;HotelBooking&gt; getAll() {
          return bookings;
      }
  }
  </code></pre>
  
  <p>BookingDemoApplication.java</p>
  
  <pre><code>package com.beniregev.bookingdemo;
  
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  
  @SpringBootApplication
  public class BookingDemoApplication {
  
      public static void main(String[] args) {
          SpringApplication.run(BookingDemoApplication.class, args);
      }
  
  }
  </code></pre>
  
  <p>I am using IntelliJ 2018.3, JDK 1.8.0_144 and Springboot.
  When I am running the server and go to "localhost:8080/bookings/all" instead of a JSON I get the following:
  <a href="https://i.stack.imgur.com/LNaxY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LNaxY.png" alt="JSON is not displayed"></a></p>
  
  <p>Why the List is not displayed as JSON? What am I missing?</p>
  
  <p>I am expecting to receive something like the following:
  <a href="https://i.stack.imgur.com/NxAOv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NxAOv.png" alt="Expected result- JSON"></a></p>
  
  <p>I will appreciate any help.</p>