title: Mapping Json Array to POJO using Jackson
body: <p>I have a JSON array of the form:</p>
  
  <pre><code>[
   [
    1232324343,
    "A",
    "B",
    3333,
    "E"
   ],
   [
    12345424343,
    "N",
    "M",
    3133,
    "R"
   ]
  ]
  </code></pre>
  
  <p>I want to map each element of the parent array to a POJO using the Jackson library. I tried this:</p>
  
  <pre><code>ABC abc = new ABC();
  ObjectMapper mapper = new ObjectMapper();
  JsonNode jsonNode = mapper.readTree(data).get("results");
  
  if (jsonNode.isArray()) {
      for (JsonNode node : jsonNode) {
          String nodeContent = mapper.writeValueAsString(node);
          abc = mapper.readValue(nodeContent,ABC.class);
  
          System.out.println("Data: " + abc.getA());
      }
  }
  </code></pre>
  
  <p>where ABC is my POJO class and abc is the object but I get the following exception:</p>
  
  <blockquote>
    <p>com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of com.demo.json.model.ABC</p>
  </blockquote>
  
  <p>EDIT:
  My POJO looks like this:</p>
  
  <pre><code>class ABC{
      long time;
      String a;
      String b;
      int status;
      String c;
  }
  </code></pre>
  
  <p>Can someone suggest a solution for this?</p>
  
  <p>EDIT 2: After consulting a lot of answers on StackOverflow and other forums, I came across one solution. I mapped the returned value of readValue() method into an array of POJO objects.</p>
  
  <pre><code>ABC[] abc = mapper.readValue(nodeContent, ABC[].class);
  </code></pre>
  
  <p>But now I am getting a separate exception</p>
  
  <blockquote>
    <p>Can not construct instance of ABC: no long/Long-argument constructor/factory method to deserialize from Number value (1552572583232)</p>
  </blockquote>
  
  <p>I have tried the following but nothing worked:
  1. Forcing Jackson to use ints for long values using</p>
  
  <pre><code>mapper.configure(DeserializationFeature.USE_LONG_FOR_INTS, true);
  </code></pre>
  
  <p>2. Using wrapper class Long instead of long in the POJO</p>
  
  <p>Can anyone help me with this?</p>