title: Jackson mapping Object or list of Object depending on json input
body: <p>I have this POJO :</p>
  
  <pre><code>public class JsonObj {
  
      private String id;
      private List&lt;Location&gt; location;
  
  
      public String getId() {
          return id;
      }
  
      public List&lt;Location&gt; getLocation() {
          return location;
      }
  
      @JsonSetter("location")
      public void setLocation(){
          List&lt;Location&gt; list = new ArrayList&lt;Location&gt;();
          if(location instanceof Location){
              list.add((Location) location);
              location = list;
          }
      }
  }
  </code></pre>
  
  <p>the "location" object from the json input can be either a simple instance of Location or an Array of Location. When it is just one instance, I get this error :</p>
  
  <pre><code>Could not read JSON: Can not deserialize instance of java.util.ArrayList out of   START_OBJECT token
  </code></pre>
  
  <p>I've tried to implement a custom setter but it didn't work. How could I do to map either a Location or a List depending on the json input?</p>