get the size of an array using jackson
<p>I've the below data in a json file.</p>

<pre><code>{  
   "product":"Data",
   "data":{  
      "zip":[  
         {  
            "codeValue":"12345",
            "distance":[  
               {  
                  "5":"a c"
               },
               {  
                  "2":"z c"
               }
            ]
         },
         {  
            "codeValue":"60089",
            "distance":[  
               {  
                  "5":"a c"
               },
               {  
                  "2":"z c"
               }
            ]
         }
      ]
   }
}
</code></pre>

<p>and I'm trying to print the <code>zip</code> size using the below code.</p>

<pre><code>public void getJsonResponse() throws Exception {
    String text = getTheData();
    System.out.println(text);
    ObjectMapper objMap = new ObjectMapper();
    Map&lt;String, Object&gt; map = objMap.readValue(text, new TypeReference&lt;Map&lt;String, Object&gt;&gt;() {
    });

    String mainMap = map.get("product").toString();
    String getData = map.get("data").toString();
    Map&lt;String, Object&gt; map1 = objMap.readValue(getData, new TypeReference&lt;Map&lt;String, Object&gt;&gt;() {
    });
    List zip = (List) map1.get("zip");
    System.out.println(zip.size());
}
</code></pre>

<p>here instead of <code>sysout</code> on <code>zip.size()</code>, if I used <code>mainMap</code>, I get the output as <strong>Data</strong>, but when I use <code>zip.size()</code>, I get some exception as </p>

<blockquote>
  <p>Exception in thread "main" com.fasterxml.jackson.core.JsonParseException: Unexpected character ('z' (code 122)): was expecting double-quote to start field name
   at [Source: java.io.StringReader@60f82f98; line: 1, column: 3]
      at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1524)
      at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:557)
      at com.fasterxml.jackson.core.base.ParserMinimalBase._reportUnexpectedChar(ParserMinimalBase.java:475)
      at com.fasterxml.jackson.core.json.ReaderBasedJsonParser._handleOddName(ReaderBasedJsonParser.java:1293)
      at com.fasterxml.jackson.core.json.ReaderBasedJsonParser._parseName(ReaderBasedJsonParser.java:1190)
      at com.fasterxml.jackson.core.json.ReaderBasedJsonParser.nextToken(ReaderBasedJsonParser.java:612)
      at com.fasterxml.jackson.databind.deser.std.MapDeserializer._readAndBindStringMap(MapDeserializer.java:412)
      at com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:312)
      at com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:26)
      at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:2993)
      at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2105)
      at onlyJava.JsonDataCAll.getJsonResponse(JsonDataCAll.java:24)
      at onlyJava.Test.main(Test.java:13)</p>
</blockquote>

<p>please let me know where have I gone wrong and how can I fix this.</p>