Parsing JSON Response using Jackson
<p>I have written a web-service and hosted in the following URL <a href="http://192.168.2.34:8081/MyWebService/facility/university" rel="nofollow">http://192.168.2.34:8081/MyWebService/facility/university</a></p>

<p>Response from this web service in JSON format is:</p>

<pre><code>{
  "university": [
    {
      "emailOfPrincipal": "prin1@gmail.com",
      "labLists": [
        {
          "instrumentLists": [
            {
              "instrumentId": "1",
              "instrumentName": "Instrument 1"
            },
            {
              "instrumentId": "2",
              "instrumentName": "instrument 2"
            }
          ],
          "labId": "11",
          "labName": "Lab 11"
        },
        {
          "instrumentLists": [
            {
              "instrumentId": "3",
              "instrumentName": "instrument 3"
            },
            {
              "instrumentId": "4",
              "instrumentName": "instrument 4"
            }
          ],
          "labId": "22",
          "labName": "Lab 22"
        }
      ],
      "univAddress": "Kolkata",
      "univId": "111",
      "univName": "University 111",
      "univPrincipalName": "Principal 1"
    },
    {
      "emailOfPrincipal": "prin2@gmail.com",
      "labLists": [
        {
          "instrumentLists": [
            {
              "instrumentId": "5",
              "instrumentName": "Instrument 5"
            },
            {
              "instrumentId": "6",
              "instrumentName": "Instrument 6"
            }
          ],
          "labId": "33",
          "labName": "Lab 33"
        },
        {
          "instrumentLists": [
            {
              "instrumentId": "7",
              "instrumentName": "Instrument 7"
            },
            {
              "instrumentId": "8",
              "instrumentName": "Instrument 8"
            }
          ],
          "labId": "44",
          "labName": "Lab 44"
        }
      ],
      "univAddress": "Bangalore",
      "univId": "222",
      "univName": "University 222",
      "univPrincipalName": "Principal 2"
    },
    {
      "emailOfPrincipal": "prin3@gmail.com",
      "labLists": [
        {
          "instrumentLists": [
            {
              "instrumentId": "9",
              "instrumentName": "Instrument 9"
            },
            {
              "instrumentId": "10",
              "instrumentName": "Instrument 10"
            }
          ],
          "labId": "55",
          "labName": "Lab 55"
        },
        {
          "instrumentLists": [
            {
              "instrumentId": "11",
              "instrumentName": "Instrument 11"
            },
            {
              "instrumentId": "12",
              "instrumentName": "Instrument 12"
            }
          ],
          "labId": "66",
          "labName": "Lab 66"
        }
      ],
      "univAddress": "Hyderabad",
      "univId": "333",
      "univName": "University 333",
      "univPrincipalName": "Principal 3"
    }
  ]
}
</code></pre>

<p>I am trying to convert JSON data into Java object using jackson api. But getting an error.
My Java Objects are:</p>

<p>University.java</p>

<pre><code>public class University {
    private int univId;
    private String univName;
    private String univAddress;
    private String univPrincipalName;
    private String emailOfPrincipal;
    private List&lt;Laboratory&gt; labLists = new ArrayList&lt;&gt;();

    //... Getter and Setter Methods...
}
</code></pre>

<p>Laboratory.java</p>

<pre><code>public class Laboratory {

    private int labId;
    private String labName;
    private List&lt;Instruments&gt; instrumentLists = new ArrayList&lt;&gt;();
    //... Getter and Setter Methods...
}
</code></pre>

<p>Instruments.java</p>

<pre><code>public class Instruments {

    private int instrumentId;
    private String instrumentName;
    private String bookingStatus;
    private Date bookingFrom;
    private Date bookingTo;
    private Date requestedTime;

    //... Getter and Setter Methods...
}
</code></pre>

<p>The Client written is:</p>

<pre><code>public class ParseJSONData {

    public static void main(String[] args) throws ClientProtocolException, IOException {
        String URL = "http://192.168.2.34:8081/MyWebService/facility/university";
        DefaultHttpClient httpclient = new DefaultHttpClient();
        HttpGet httpget = new HttpGet(URL);
        HttpResponse response = httpclient.execute(httpget);
        // System.out.println(response);

        HttpEntity entity = response.getEntity();
        String result = EntityUtils.toString(entity);

        ObjectMapper mapper = new ObjectMapper();

        University universities = mapper.readValue(result, University.class);
        System.out.println(universities.getEmailOfPrincipal());
    }
</code></pre>

<p>The error I am getting says </p>

<pre><code>Exception in thread "main" org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field "university" (Class University), not marked as ignorable
 at [Source: java.io.StringReader@100edc0; line: 1, column: 16] (through reference chain: University["university"])
</code></pre>

<p>I know my JSON data is returning List of universities. But how to map those in List I am not aware of. Any sort of help will be greatly appreciated.</p>