title: Deserialize nested array as ArrayList with Jackson
body: <p>I have a piece of JSON, that looks like this:</p>
  
  <pre><code>{
    "authors": {
      "author": [
        {
          "given-name": "Adrienne H.",
          "surname": "Kovacs"
        },
        {
          "given-name": "Philip",
          "surname": "Moons"
        }
      ]
     }
   }
  </code></pre>
  
  <p>I have created a class to store Author information:</p>
  
  <pre><code>public class Author {
      @JsonProperty("given-name")
      public String givenName;
      public String surname;
  }
  </code></pre>
  
  <p>And two wrapper classes:</p>
  
  <pre><code>public class Authors {
      public List&lt;Author&gt; author;
  }
  
  public class Response {
      public Authors authors;
  }
  </code></pre>
  
  <p>This is working, but having two wrapper classes seems to be unnecessary. I want to find a way to remove <code>Authors</code> class and have a list as a property of Entry class. Is something like that is possible with Jackson?</p>
  
  <h1>Update</h1>
  
  <p>Solved that with custom deserializer:</p>
  
  <pre><code>public class AuthorArrayDeserializer extends JsonDeserializer&lt;List&lt;Author&gt;&gt; {
  
      private static final String AUTHOR = "author";
      private static final ObjectMapper mapper = new ObjectMapper();
      private static final CollectionType collectionType =
              TypeFactory
              .defaultInstance()
              .constructCollectionType(List.class, Author.class);
  
      @Override
      public List&lt;Author&gt; deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
              throws IOException, JsonProcessingException {
  
          ObjectNode objectNode = mapper.readTree(jsonParser);
          JsonNode nodeAuthors = objectNode.get(AUTHOR);
  
          if (null == nodeAuthors                     // if no author node could be found
                  || !nodeAuthors.isArray()           // or author node is not an array
                  || !nodeAuthors.elements().hasNext())   // or author node doesn't contain any authors
              return null;
  
          return mapper.reader(collectionType).readValue(nodeAuthors);
      }
  }
  </code></pre>
  
  <p>And using it like this: </p>
  
  <pre><code>@JsonDeserialize(using = AuthorArrayDeserializer.class)
  public void setAuthors(List&lt;Author&gt; authors) {
      this.authors = authors;
  }
  </code></pre>
  
  <p>Thanks @wassgren for the idea.</p>