Java Code Examples for com.github.openjson.JSONObject#has()
The following examples show how to use
com.github.openjson.JSONObject#has() .
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: Whiteboard.java From openmeetings with Apache License 2.0 | 6 votes |
public JSONObject toJson() { //deep-copy JSONObject json = new JSONObject(new JSONObject(this).toString(new NullStringer())); json.remove("id"); //filtering json.remove("empty"); //filtering JSONObject items = new JSONObject(); for (Entry<String, String> e : roomItems.entrySet()) { JSONObject o = new JSONObject(e.getValue()); //filtering if ("Clipart".equals(o.opt(ATTR_OMTYPE))) { if (o.has(PARAM__SRC)) { o.put(PARAM_SRC, o.get(PARAM__SRC)); } } else { o.remove(PARAM_SRC); } o.remove(PARAM__SRC); items.put(e.getKey(), o); } json.put(ITEMS_KEY, items); return json; }
Example 2
Source File: AppointmentParamConverter.java From openmeetings with Apache License 2.0 | 5 votes |
@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; }
Example 3
Source File: UserParamConverter.java From openmeetings with Apache License 2.0 | 5 votes |
@Override public UserDTO fromString(String val) { JSONObject o = new JSONObject(val); if (o.has(ROOT)) { o = o.getJSONObject(ROOT); } return UserDTO.get(o); }
Example 4
Source File: DtoHelper.java From openmeetings with Apache License 2.0 | 4 votes |
public static Integer optInt(JSONObject o, String key) { return o.has(key) && !o.isNull(key) ? o.getInt(key) : null; }
Example 5
Source File: DtoHelper.java From openmeetings with Apache License 2.0 | 4 votes |
public static Long optLong(JSONObject o, String key) { return o.has(key) && !o.isNull(key) ? o.getLong(key) : null; }
Example 6
Source File: DtoHelper.java From openmeetings with Apache License 2.0 | 4 votes |
public static <T extends Enum<T>> T optEnum(Class<T> clazz, JSONObject o, String key) { return o.has(key) && !o.isNull(key) ? Enum.valueOf(clazz, o.getString(key)) : null; }