title: deserialize a json array into a java object holding list
body: <p>I'm getting a json array holding objects looking like this:</p>
  <pre><code>[
      {
          &quot;id&quot;: &quot;1&quot;,
          &quot;name&quot;: &quot;some name&quot;,
          &quot;url&quot;: &quot;some url&quot;,
          &quot;active&quot;: true
      }, {
          &quot;id&quot;: &quot;2&quot;,
          &quot;name&quot;: &quot;some other name&quot;,
          &quot;url&quot;: &quot;some other url&quot;,
          &quot;active&quot;: true
      }
  ]
  </code></pre>
  <p>Now, I want to be able to deserialize that array into a java object holding a list of the objects in the array. I have made a custom deserializer looking like this:</p>
  <pre><code>public class ListSerializer extends JsonDeserializer&lt;List&lt;Provider&gt;&gt;{
  
      private static final long serialVersionUID = 9114152571639338391L;
  
      @Override
      public List&lt;Provider&gt; deserialize(JsonParser jsonParser, 
      DeserializationContext arg1) throws IOException, JsonProcessingException {
      // TODO Auto-generated method stub
      final ObjectCodec objectCodec = jsonParser.getCodec();
      final JsonNode listOrObjectNode = objectCodec.readTree(jsonParser);
      final List&lt;Provider&gt; result = new ArrayList&lt;Provider&gt;();
      for (JsonNode node : listOrObjectNode) {
        result.add(objectCodec.treeToValue(node, Provider.class));
      }
        return result;
      }
  }
  </code></pre>
  <p>And the class holding the list looks like this:</p>
  <pre><code>public class ProviderList {
  
      @JsonDeserialize(using = ListSerializer.class)
      private List&lt;Provider&gt; providerList;
  
       public List&lt;Provider&gt; getProviderList() {
        return providerList;
      }
  
      public void setProviderList(final List&lt;Provider&gt; providerList) {
        this.providerList = providerList;
       }
  }
  </code></pre>
  <p>I am obviously doing something wrong, because I'm getting this error:</p>
  <blockquote>
  <p>Can not deserialize instance of
  com.wirelesscar.trailser.v1_0.domain.ProviderList out of START_ARRAY
  token  at [Source:
  [{&quot;id&quot;:&quot;1&quot;,&quot;name&quot;:&quot;Posttrack&quot;,&quot;url&quot;:&quot;http:\dev.posttrack.com&quot;,&quot;active&quot;:true},{&quot;id&quot;:&quot;2&quot;,&quot;name&quot;:&quot;Trackunit&quot;,&quot;url&quot;:&quot;http:\dev.trackunit.com&quot;,&quot;active&quot;:true}];
  line: 1, column: 1]</p>
  </blockquote>
  <p>How can I do this properly?</p>