Java Code Examples for com.github.openjson.JSONObject#optJSONArray()

The following examples show how to use com.github.openjson.JSONObject#optJSONArray() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RoomDTO.java    From openmeetings with Apache License 2.0 5 votes vote down vote up
public static RoomDTO get(JSONObject o) {
	if (o == null) {
		return null;
	}
	RoomDTO r = new RoomDTO();
	r.id = optLong(o, "id");
	r.name = o.optString("name");
	r.tag = o.optString("tag");
	r.comment = o.optString("comment");
	r.type = optEnum(Room.Type.class, o, "type");
	if (r.type == null) {
		throw new IllegalArgumentException("Room should have valid type");
	}
	r.capacity = o.optLong("capacity", 4);
	r.appointment = o.optBoolean("appointment", false);
	r.confno = o.optString("confno");
	r.isPublic = o.optBoolean("isPublic", false);
	r.demo = o.optBoolean("demo", false);
	r.closed = o.optBoolean("closed", false);
	r.demoTime = optInt(o, "demoTime");
	r.externalId = o.optString("externalId", null);
	r.externalType = o.optString("externalType", null);
	r.redirectUrl = o.optString("redirectUrl");
	r.moderated = o.optBoolean("moderated", false);
	r.waitModerator = o.optBoolean("waitModerator", false);
	r.allowUserQuestions = o.optBoolean("allowUserQuestions", false);
	r.allowRecording = o.optBoolean("allowRecording", false);
	r.waitRecording = o.optBoolean("waitRecording", false);
	r.audioOnly = o.optBoolean("audioOnly", false);
	r.getHiddenElements().addAll(optEnumList(RoomElement.class, o.optJSONArray("hiddenElements")));
	JSONArray fa = o.optJSONArray("files");
	if (fa != null) {
		for (int i = 0; i < fa.length(); ++i) {
			r.getFiles().add(RoomFileDTO.get(fa.getJSONObject(i)));
		}
	}
	return r;
}
 
Example 2
Source File: AppointmentParamConverter.java    From openmeetings with Apache License 2.0 5 votes vote down vote up
@Override
public AppointmentDTO fromString(String val) {
	JSONObject o = new JSONObject(val);
	if (o.has(ROOT)) {
		o = o.getJSONObject(ROOT);
	}
	AppointmentDTO a = new AppointmentDTO();
	a.setId(optLong(o, "id"));
	a.setTitle(o.optString("title"));
	a.setLocation(o.optString("location"));
	a.setOwner(UserDTO.get(o.optJSONObject("owner")));
	String tzId = a.getOwner() == null ? null : a.getOwner().getTimeZoneId();
	a.setStart(CalendarParamConverter.get(o.optString("start"), tzId));
	a.setEnd(CalendarParamConverter.get(o.optString("end"), tzId));
	a.setDescription(o.optString("description"));
	a.setInserted(DateParamConverter.get(o.optString("inserted")));
	a.setUpdated(DateParamConverter.get(o.optString("updated")));
	a.setDeleted(o.optBoolean("deleted"));
	a.setReminder(optEnum(Reminder.class, o, "reminder"));
	a.setRoom(RoomDTO.get(o.optJSONObject("room")));
	a.setIcalId(o.optString("icalId"));
	JSONArray mm = o.optJSONArray("meetingMembers");
	if (mm != null) {
		for (int i = 0; i < mm.length(); ++i) {
			a.getMeetingMembers().add(MeetingMemberDTO.get(mm.getJSONObject(i)));
		}
	}
	a.setLanguageId(o.optLong("languageId"));
	a.setPassword(o.optString("password"));
	a.setPasswordProtected(o.optBoolean("passwordProtected"));
	a.setConnectedEvent(o.optBoolean("connectedEvent"));
	a.setReminderEmailSend(o.optBoolean("reminderEmailSend"));
	return a;
}