public JSONObject toJSON() throws Exception {

    JSONObject jsonObj = new JSONObject();
    jsonObj.put("avgRating", this.avgRating);
    jsonObj.put("distance", this.distance);
    jsonObj.put("address", this.address);
    jsonObj.put("lat", this.lat);
    jsonObj.put("lng", this.lng);
    jsonObj.put("name", this.name != null ? this.name : "");
    jsonObj.put("stars", this.stars);
    jsonObj.put("votes", this.votes);
    jsonObj.put("dataLink", this.dataLink != null ? this.dataLink : "");
    JSONArray hRooms = new JSONArray();
    jsonObj.put("rooms", hRooms);
    if (this.rooms != null) {
      for (TRoomData room : this.rooms) {
        hRooms.put(room.toJSON());
      }
    }

    jsonObj.put("cancelable", this.cancelable);
    jsonObj.put("withBreakfast", this.withBreakfast);
    jsonObj.put("ranking", this.ranking);
    jsonObj.put("avgDayPrice", this.avgDayPrice);
    jsonObj.put("avgPrice", this.avgPrice);
    jsonObj.put("avgCalculatedPrice", this.avgCalculatedPrice);

    return jsonObj;
  }
 /** @see java.lang.Object#toString() */
 @Override
 public String toString() {
   String cad =
       "HotelData = { Name = '"
           + name
           + "', Stars = "
           + stars
           + ", Rating = "
           + avgRating
           + "/"
           + votes
           + ", Address = "
           + address
           + ", Distance = "
           + distance
           + ", Lat = "
           + lat
           + ", lng = "
           + lng;
   if (rooms != null)
     for (TRoomData room : rooms) {
       cad += "\n  " + room.toString();
     }
   cad += "\n}";
   return cad;
 }
  public static THotelData fromJSON(JSONObject jsonObj) throws Exception {

    THotelData hotel = new THotelData();
    hotel.avgRating = jsonObj.getDouble("avgRating");
    hotel.distance = jsonObj.getDouble("distance");
    hotel.address = jsonObj.getString("address");
    hotel.lat = jsonObj.getDouble("lat");
    hotel.lng = jsonObj.getDouble("lng");
    hotel.name = jsonObj.getString("name");
    hotel.stars = jsonObj.getInt("stars");
    hotel.votes = jsonObj.getInt("votes");
    hotel.dataLink = jsonObj.getString("dataLink");
    JSONArray hRooms = jsonObj.getJSONArray("rooms");
    if (hRooms.length() > 0) {
      hotel.rooms = new ArrayList<TRoomData>();
      for (int n = 0; n < hRooms.length(); n++) {
        TRoomData room = TRoomData.fromJSON(hotel, (JSONObject) hRooms.get(n));
        hotel.rooms.add(room);
      }
    }

    hotel.cancelable = jsonObj.getBoolean("cancelable");
    hotel.withBreakfast = jsonObj.getBoolean("withBreakfast");
    hotel.ranking = jsonObj.getInt("ranking");
    hotel.avgDayPrice = jsonObj.getDouble("avgDayPrice");
    hotel.avgPrice = jsonObj.getDouble("avgPrice");
    hotel.avgCalculatedPrice = jsonObj.getDouble("avgCalculatedPrice");

    return hotel;
  }