title: Create a JSON structure from set of Java Pojo classes
body: <p>I need to create a JSON object structure from set of java pojo classes. This will provide a better understand of how the objects are structured by just looking at the Json file. I tried both  Gson  and org.codehaus.jackson.map.ObjectMapper libraries. But couldn't generate all the Json tags relevant to all the fields in java pojo objects. The created json file is only having the values from the values stetted objects. I need to have all the fields of pojo objects in the Json file.</p>
  
  <p>Gson</p>
  
  <pre><code>        Hotel hotel = new Hotel(); //This hotel object includes multiple objects and those objects also include multiple objects, lists
          Gson gson = new GsonBuilder().create();
          String json = gson.toJson(hotel);
          System.out.println(json);
  </code></pre>
  
  <p>ObjectMapper</p>
  
  <pre><code>ObjectMapper mapper = new ObjectMapper();
  mapper.writeValue(new File("/home/Pojos.json");
  </code></pre>
  
  <p>This is the class and json response I got. </p>
  
  <p>Hotel.java</p>
  
  <pre><code>
  package datatypes;
  
  import java.util.ArrayList;
  import java.util.List;
  
  public class Hotel {
  
  
      private     String      hotelCode;
      private     String      chainCode;
      private     String      hotelName;
      private     List&lt;Room&gt;  rooms           =   new ArrayList&lt;Room&gt;(); 
      private     List&lt;RoomRateRestriction&gt;   roomRateRestrictions
      =   new ArrayList&lt;RoomRateRestriction&gt;();
  
  
      public String getHotelCode() {
          return hotelCode;
      }
      public void setHotelCode(String hotelCode) {
          this.hotelCode = hotelCode;
      }
      public String getChainCode() {
          return chainCode;
      }
      public void setChainCode(String chainCode) {
          this.chainCode = chainCode;
      }
      public String getHotelName() {
          return hotelName;
      }
      public void setHotelName(String hotelName) {
          this.hotelName = hotelName;
      }
      public List&lt;Room&gt; getRooms() {
          return rooms;
      }
      public void setRooms(List&lt;Room&gt; rooms) {
          this.rooms = rooms;
      }
  
      public void addRoom(Room room){
          this.rooms.add(room);
      }
      public List&lt;RoomRateRestriction&gt; getRoomRateRestrictions() {
          return roomRateRestrictions;
      }
      public void setRoomRateRestrictions(
              List&lt;RoomRateRestriction&gt; roomRateRestrictions) {
          this.roomRateRestrictions = roomRateRestrictions;
      }
  
      public void addRoomRateRestrictions(
              RoomRateRestriction roomRateRestriction) {
          this.roomRateRestrictions.add(roomRateRestriction);
      }
  }
  
  </code></pre>
  
  <h2>JSON</h2>
  
  <pre><code>   {
       "rooms":[],
       "roomRateRestrictions":[]
     }
  </code></pre>