public JSONObject toJson() { JSONObject data = new JSONObject(); data.put("Id", id); data.put("Name", name); data.put("IconUrl", iconUrl); data.put("Settings", settings.toJson()); if (botNick != null && !botNick.equals("")) data.put("BotNick", botNick); data.put("ManageServer", manageServer); data.put("DiscalRole", discalRole); JSONArray jRoles = new JSONArray(); for (WebRole wr : roles) { jRoles.put(wr.toJson()); } data.put("Roles", jRoles); JSONArray jChannels = new JSONArray(); for (WebChannel wc : channels) { jChannels.put(wc.toJson()); } data.put("Channels", jChannels); JSONArray jAnnouncements = new JSONArray(); for (Announcement a : announcements) { jAnnouncements.put(a.toJson()); } data.put("Announcements", jAnnouncements); data.put("Calendar", calendar.toJson()); return data; }