title: JAVA Jackson Parsing JSON Response that Contains List/Array
body: <p>I'm trying to deserialize a JSON string but I keep running into JSON Mapping Exception. I've been scouring the internet but have had little luck.</p>
  
  <p>My JSON response that I'm trying to deserialize looks like the following:</p>
  
  <pre><code>{
     "comments": [{
           "id": "fa6491aeb",
           "user": {
              "userId": "e4dddf5e1",
              "username": "UserX",
              "name": "UserX",
              "profilePhotoUri": ""
           },
           "message": "8: 23 - UserX",
           "timestamp": 1429844781919
        },{
           "id": "ed3e71",
           "user": {
              "userId": "20b8f1",
              "username": "UserW",
              "name": "UserW",
              "profilePhotoUri": ""
           },
           "message": "8: 22 - UserW",
           "timestamp": 1429844780250
        },
        //... more items
     ],
     "canCallerComment": true
  }
  </code></pre>
  
  <p>Here is an abridged version of the error I get:</p>
  
  <pre><code>com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of com.test.android.CommentsResponse out of START_ARRAY token
      at [Source: [{"user":{"userId":"fa6491aeb", ..........]; line: 1, column: 1]
      at com.fasterxml.jackson.databind.DeserializationContext.mappingException(DeserializationContext.java:835)
      at com.fasterxml.jackson.databind.DeserializationContext.mappingException(DeserializationContext.java:831)
      at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromArray(BeanDeserializerBase.java:1220)
      at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeOther(BeanDeserializer.java:165)
      ...
  </code></pre>
  
  <p>I tried wrapping my response as mentioned in <a href="https://stackoverflow.com/a/29826740/1877617">this post</a>, but I still get the same error. From the call stack-trace, it seems likes it has something to do with <strong>List&lt;Comment&gt;</strong>. I.e, I need to pass a list object. Is this <strong>objectMapper.readValue(json, CommentResponse.class)</strong> not sufficient?</p>
  
  <p>My JAVA classes are defined as follows:</p>
  
  <pre><code>public class Comment {
      private String id;
      private User user;
      private String message;
      private long timestamp;
      // getter/setters
  }
  
  public class CommentResponse {
      List&lt;Comment&gt; comments;
      boolean canCallerComment = false;
      // getter/setters
  }
  </code></pre>
  
  <p>If it helps, I'm using Jackson version 2.5.3; and the targeted platform is Android.</p>
  
  <p><strong>Edit:</strong>
  Sparks solution below is correct. I had a typo where I was trying to parse JSON from the wrong web service.</p>