title: i'm getting an exception when retrieving a list of Jsonobjects using springs RESTtemplate
body: <p>I am trying to get a list of Json objects from a REST webservice. I'm able to do the actual get request but when Spring tries to deserialize the object I get the following exception:</p>
  
  <pre><code>org.springframework.http.converter.HttpMessageNotReadableException: Could not read document: Can not deserialize instance of java.util.ArrayList out of START_OBJECT token
   at [Source: java.io.PushbackInputStream@593f72fb; line: 1, column: 1]; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.util.ArrayList out of START_OBJECT token
   at [Source: java.io.PushbackInputStream@593f72fb; line: 1, column: 1]
          at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.readJavaType(AbstractJackson2HttpMessageConverter.java:228) ~[spring-web-4.3.2.RELEASE.jar:4.3.2.RELEASE]
          at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.read(AbstractJackson2HttpMessageConverter.java:213) ~[spring-web-4.3.2.RELEASE.jar:4.3.2.RELEASE]
          at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:95) ~[spring-web-4.3.2.RELEASE.jar:4.3.2.RELEASE]
          at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:884) ~[spring-web-4.3.2.RELEASE.jar:4.3.2.RELEASE]
          at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:868) ~[spring-web-4.3.2.RELEASE.jar:4.3.2.RELEASE]
          at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:622) ~[spring-web-4.3.2.RELEASE.jar:4.3.2.RELEASE]
          at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:580) ~[spring-web-4.3.2.RELEASE.jar:4.3.2.RELEASE]
          at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:526) ~[spring-web-4.3.2.RELEASE.jar:4.3.2.RELEASE]
          at nl.enshore.chatstreamer.service.SmartsuppRestServiceImpl.listTriggers(SmartsuppRestServiceImpl.java:36) ~[main/:na]
          at nl.enshore.chatstreamer.smack.TSmackMessageHandler.handleChatMessage(TSmackMessagr.java:81) ~[main/:na]
          at nl.enshore.chatmanager.listeners.HandledMessageListener.processMessage(HandledMessageListener.java:32) ~[enshore-chat-connection-1.1.2.jar:1.1.2]
          at org.jivesoftware.smack.chat.Chat.deliver(Chat.java:180) ~[smack-im-4.1.0.jar:4.1.0]
          at org.jivesoftware.smack.chat.ChatManager.deliverMessage(ChatManager.java:351) ~[smack-im-4.1.0.jar:4.1.0]
          at org.jivesoftware.smack.chat.ChatManager.access$300(ChatManager.java:53) ~[smack-im-4.1.0.jar:4.1.0]
          at org.jivesoftware.smack.chat.ChatManager$2.processPacket(ChatManager.java:162) ~[smack-im-4.1.0.jar:4.1.0]
          at org.jivesoftware.smack.AbstractXMPPConnection$4.run(AbstractXMPPConnection.java:1126) ~[smack-core-4.1.0.jar:4.1.0]
          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_131]
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_131]
          at java.lang.Thread.run(Thread.java:748) [na:1.8.0_131]
  Caused by: com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.util.ArrayList out of START_OBJECT token
   at [Source: java.io.PushbackInputStream@593f72fb; line: 1, column: 1]
          at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:148) ~[jackson-databind-2.6.1.jar:2.6.1]
          at com.fasterxml.jackson.databind.DeserializationContext.mappingException(DeserializationContext.java:854) ~[jackson-databind-2.6.1.jar:2.6.1]
          at com.fasterxml.jackson.databind.DeserializationContext.mappingException(DeserializationContext.java:850) ~[jackson-databind-2.6.1.jar:2.6.1]
          at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.handleNonArray(CollectionDeserializer.java:292) ~[jackson-databind-2.6.1.jar:2.6.1]
          at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:227) ~[jackson-databind-2.6.1.jar:2.6.1]
          at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:217) ~[jackson-databind-2.6..6.1]:2
          at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:25) ~[jackson-databind-2.6.1.jar:2.6.1]
          at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3702) ~[jackson-databind-2.6.1.jar:2.6.1]
          at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2798) ~[jackson-databind-2.6.1.jar:2.6.1]
          at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.readJavaType(AbstractJackson2HttpMessageConverter.java:225) ~[spring-web-4.3.2.RELEASE.jar:4.3.2.RELEASE]
          ... 18 common frames omitted
  </code></pre>
  
  <p>Here is an example of a list of Json objects that I want to retrieve:</p>
  
  <pre><code>{
    "records": [{
      "id": 563,
      "active": true,
      "name": "1st visit greeting",
      "description": "Greeting message to a visitor who visits your website for the 1st time"
    }, {
      "id": 564,
      "active": false,
      "name": "2st visit greeting",
      "description": "Greeting message to a visitor who visits your website for the 2nd time"
    }]
  }
  </code></pre>
  
  <p>heres the POJO I use to turn the jsonObjects into Java objects.</p>
  
  <pre><code>@JsonIgnoreProperties(ignoreUnknown = true)
  public class Trigger {
  
      private long id;
  
      @JsonProperty("name")
      private String triggerName;
  
      private String description;
  
      public long getId() {
          return id;
      }
  
      public void setId(long id) {
          this.id = id;
      }
  
      public String getTriggerName() {
          return triggerName;
      }
  
      public void setTriggerName(String triggerName) {
          this.triggerName = triggerName;
      }
  
      public String getDescription() {
          return description;
      }
  
      public void setDescription(String description) {
          this.description = description;
      }
  
      @Override
      public String toString() {
          return "Trigger{" +
                  "id=" + id +
                  ", triggerName='" + triggerName + '\'' +
                  ", description='" + description + '\'' +
                  '}';
      }
  }
  </code></pre>
  
  <p>and heres the service class I've made that uses springs REST template to make the GET request.</p>
  
  <pre><code>@Service
  public class SmartsuppRestServiceImpl implements SmartsuppRestService {
  
      private final RestTemplate restTemplate;
  
      @Autowired
      public SmartsuppRestServiceImpl(RestTemplate restTemplate){
          this.restTemplate = restTemplate;
      }
  
      @Override
      public List&lt;Trigger&gt; listTriggers(String accountId){
          HttpHeaders apiKeyHeader = new HttpHeaders();
          apiKeyHeader.set("apiKey", "************");
          HttpEntity entity = new HttpEntity(apiKeyHeader);
  
          ResponseEntity&lt;List&lt;Trigger&gt;&gt; getResponse = restTemplate.exchange("https://api.smartsupp.com/accounts/****/triggers"
                  , HttpMethod.GET, entity, new ParameterizedTypeReference&lt;List&lt;Trigger&gt;&gt;(){});
          return getResponse.getBody();
      }
  
     // public Trigger getTrigger(int triggerId){}
  
  
  
  }
  </code></pre>
  
  <p>(the parameter accountId is being ignored on purpose, I've hardcoded the accountID in the url for testing purposes).</p>
  
  <p>Can anyone see what i'm doing wrong?</p>
  
  <p>Thank you.</p>