title: How to convert json String to java object
body: <p>From jsp through ajax cal I'm passing json string to server and I am converting to json object. How can I convert the jsonobject to a model class object in java?</p>
  
  <p>In server I'm doing this: </p>
  
  <pre><code> HttpServletRequest request = ServletActionContext.getRequest();
   String jsonData = request.getParameter("JsonData");
   JSONObject jsonDataObject = (JSONObject) JSONSerializer.toJSON( jsonData );
  </code></pre>
  
  <p>My model classes looks like this:</p>
  
  <pre><code>   public class Vehicles {
  
  private List&lt;Vehicle&gt; vehicle;
  
  public List&lt;Vehicle&gt; getVehicle() {
      return vehicle;
  }
  
  public void setVehicle(List&lt;Vehicle&gt; vehicle) {
      this.vehicle= vehicle;
  }
  
      }
  </code></pre>
  
  <p>And</p>
  
  <pre><code>  public class Vehicle{
      private Integer vId;
     private String VName;
      private List&lt;Department&gt; department;
     //getters and setters;
      }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>  public class Department{
      private Integer depId;
  private String departmentName;
  private List&lt;Item&gt; item;
     //getters and setters
     }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>  public class Item{
    private Integer itemId;
    private String itemName;
    //getters and setters
     }
  </code></pre>
  
  <p>and I am getting jsonData String as</p>
  
  <pre><code>{"vehicles":[{"vehicle":[{"department":[{"Item":[{"itemId":31,"itemName":"c7"},{"itemId":32,"itemName":"c2"}],"depId":21,"departmentName":"d1"}],"vId":11,"VName":"aaa"},{"department":[{"Item":[{"itemId":33,"itemName":"c3"},{"itemId":34,"itemName":"c4"}],"depId":22,"departmentName":"d2"},{"Item":[{"itemId":36,"itemName":"c1"}],"depId":24,"departmentName":"d3"}],"vId":12,"VName":"bbbb"},{"department":[{"Item":[{"itemId":30,"itemName":"c6"},{"itemId":35,"itemName":"c5"}],"depId":23,"departmentName":"d4"}],"vId":13,"VName":"cccc"},{"department":[{"Item":[{"itemid":37,"itemName":"c8","status":0}],"depId":25,"departmentName":"d5"}],"vId":14,"VName":"ddd"}]}]}
  </code></pre>
  
  <p>How can I convert JSONObject jsonDataObject ( or String jsonData)  to model class object(ie vehicles) in java?</p>