title: Exception: Can not deserialize instance of java.util.ArrayList out of START_OBJECT token at
body: <p>I am trying to display data from a web service and getting this error : 
  <strong>Exception in thread "main" com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.util.ArrayList out of START_OBJECT token at...</strong></p>
  
  <p>Find below my code :</p>
  
  <p><strong>Model object :</strong></p>
  
  <pre><code>public class Commune implements Serializable{
  
      private static final long serialVersionUID = 1L;
  
      private String name;
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      @Override
      public String toString() {
          return "Commune [name=" + name + "]";
      }
  }
  </code></pre>
  
  <p><strong>Main class:</strong></p>
  
  <pre><code>public class Test {
  
      public static void main(String[] args) throws IOException {
  
          URL url = new URL("https://bj-decoupage-territorial.herokuapp.com/api/v1/towns");
          HttpURLConnection connection = (HttpURLConnection) url.openConnection();
          connection.setRequestMethod("GET");
          connection.setRequestProperty("Accept", "application/json");
  
          if(connection.getResponseCode() != 200){
              throw new RuntimeException("Failed : Http code : "+connection.getResponseCode());
          }
  
          BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
  
          String output;
  
          while((output = reader.readLine()) != null){
  
              ObjectMapper mapper = new ObjectMapper();
              TypeReference&lt;List&lt;Commune&gt;&gt; mapType = new TypeReference&lt;List&lt;Commune&gt;&gt;() {};
              List&lt;Commune&gt; jsonToCommuneList = mapper.readValue(output, mapType);
  
              for(Commune c : jsonToCommuneList) {
                  System.out.println(c.getName());
              }
          }
          connection.disconnect();        
      }
  }
  </code></pre>
  
  <p>Here is the data getting from the url : </p>
  
  <pre><code>{"towns":
     [
        {"name":"BANIKOARA"},
        {"name":"GOGOUNOU"},
        {"name":"KANDI"},
        {"name":"KARIMAMA"}
     ]
  }
  </code></pre>
  
  <p>Help me please to check what i did wrong.</p>
  
  <p>Thank you</p>