title: Deserialize ArrayList from String using Jackson ACCEPT_SINGLE_VALUE_AS_ARRAY
body: <p>Problem Deserializing array as string with Jackson 2</p>
  
  <p>This is a similar problem to <a href="https://stackoverflow.com/questions/10247639/deserialize-arraylist-from-string-using-jackson/12716423#12716423">Deserialize ArrayList from String using Jackson</a></p>
  
  <p>The incoming JSON (which I can't control) has an element 'thelist' which is an array.
  However, sometimes this comes in as an empty string instead of an array:</p>
  
  <p>eg. instead of <strong>"thelist" : [ ]</strong><br>
  it comes in as <strong>"thelist" : ""</strong></p>
  
  <p>I'm having trouble parsing both cases.</p>
  
  <p>The <strong>'sample.json'</strong> file which works fine:</p>
  
  <pre><code>{
     "name" : "widget",
     "thelist" : 
      [
         {"height":"ht1","width":"wd1"}, 
         {"height":"ht2","width":"wd2"}
      ]
  }
  </code></pre>
  
  <p>The classes:</p>
  
  <pre><code>public class Product { 
      private String name; 
      private List&lt;Things&gt; thelist; 
      // with normal getters and setters not shown
  }
  
  public class Things {
          String height;
          String width;
          // with normal getters and setters not shown
  }
  </code></pre>
  
  <p>The code that works fine:</p>
  
  <pre><code>import com.fasterxml.jackson.core.JsonParseException;
  import com.fasterxml.jackson.databind.DeserializationFeature;
  import com.fasterxml.jackson.databind.JsonMappingException;
  import com.fasterxml.jackson.databind.ObjectMapper;
  
  public class Test2 {
   public static void main(String[] args) 
      {
          ObjectMapper mapper = new ObjectMapper(); 
          Product product = mapper.readValue( new File("sample.json"), Product.class);
      }
  }
  </code></pre>
  
  <p>However, when the JSON has got an empty string instead of an array, ie. <strong>"thelist" : ""</strong> <br>
  I get this error:</p>
  
  <pre><code>com.fasterxml.jackson.databind.JsonMappingException: Can not instantiate value of type [collection type; class java.util.ArrayList, contains [simple type, class com.test.Things]] from JSON String; no single-String constructor/factory method (through reference chain: com.test.Product["thelist"])
  </code></pre>
  
  <p>If I add this line (which works for Ryan in <a href="https://stackoverflow.com/questions/10247639/deserialize-arraylist-from-string-using-jackson/12716423#12716423">Deserialize ArrayList from String using Jackson</a> and seemingly supported by the documentation), </p>
  
  <pre><code>mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
  </code></pre>
  
  <p>it makes no difference.</p>
  
  <p><strong>Is there some other setting, or do I need to write a custom deserializer?</strong><br>
  If the latter, is there a simple example of doing this with Jackson 2.0.4 ?<br>
  I'm new to Jackson (and first time poster, so be gentle). I have done lots of searching, but can't find a good working example.</p>