List of usage examples for org.json JSONObject getBoolean
public boolean getBoolean(String key) throws JSONException
From source file:com.tedx.logics.AttendeeLogic.java
public static Bundle GetCurrentDancers(Resources res, String EventUniqueId) { String Action = "GetAttendeeByUniqueId"; JSONObject requestJSONParameters = new JSONObject(); try {// w w w. ja v a 2s .c om requestJSONParameters.put("EventId", Integer.valueOf(res.getString(R.string.eventId))); requestJSONParameters.put("EventUniqueId", EventUniqueId); } catch (JSONException e) { // TODO Auto-generated catch block return null; } String URL = res.getString(R.string.WebServiceAddress) + Action; JSONObject responseJSON = WebServices.SendHttpPost(URL, requestJSONParameters); if (responseJSON != null) { try { if (responseJSON.getBoolean("IsSuccessful")) { Bundle ret = new Bundle(); ret.putInt("AttendeeId", responseJSON.getInt("AttendeeId")); ret.putString("FirstName", responseJSON.getString("FirstName")); ret.putString("LastName", responseJSON.getString("LastName")); ret.putString("ContactNumber", responseJSON.getString("ContactNumber")); ret.putString("Website", responseJSON.getString("Website")); ret.putString("Email", responseJSON.getString("Email")); ret.putString("Facebook", responseJSON.getString("Facebook")); ret.putString("Twitter", responseJSON.getString("Twitter")); ret.putString("Description", responseJSON.getString("Description")); return ret; } else return null; } catch (JSONException e) { // TODO Auto-generated catch block return null; } } else return null; }
From source file:com.snappy.couchdb.CouchDBHelper.java
/** * Create user response object//from w w w. ja v a 2 s . co m * * @param json * @return * @throws JSONException */ public static String createUser(JSONObject json) throws JSONException { boolean ok = false; String id = null; if (json != null) { if (json.has(Const.ERROR)) { appLogout(null, false, isInvalidToken(json)); return null; } ok = json.getBoolean(Const.OK); id = json.getString(Const.ID); } if (!ok) { Logger.error(TAG + "createUser", "error in creating user"); } return id; }
From source file:com.snappy.couchdb.CouchDBHelper.java
/** * JSON response from deleting a group//from www .j ava 2 s .c om * * @param json * @return * @throws JSONException */ public static boolean deleteGroup(JSONObject json) throws JSONException { boolean ok = false; if (json != null) { if (json.has(Const.ERROR)) { appLogout(false, false, isInvalidToken(json)); return false; } ok = json.getBoolean(Const.OK); } return ok; }
From source file:com.snappy.couchdb.CouchDBHelper.java
/** * JSON response from deleting a user group * /*from w w w . j a v a 2s . c o m*/ * @param json * @return * @throws JSONException */ public static boolean deleteUserGroup(JSONObject json) throws JSONException { boolean ok = false; if (json != null) { if (json.has(Const.ERROR)) { appLogout(false, false, isInvalidToken(json)); return false; } ok = json.getBoolean(Const.OK); } return ok; }
From source file:com.snappy.couchdb.CouchDBHelper.java
/** * JSON response from creating a user group * // w w w .j a v a 2 s .c o m * @param json * @return * @throws JSONException */ public static String createUserGroup(JSONObject json) throws JSONException { boolean ok = false; String id = null; if (json != null) { if (json.has(Const.ERROR)) { appLogout(null, false, isInvalidToken(json)); return null; } ok = json.getBoolean(Const.OK); id = json.getString(Const.ID); } if (!ok) { Logger.error(TAG + "createUserGroup", "error in creating a group"); return null; } return id; }
From source file:com.snappy.couchdb.CouchDBHelper.java
/** * Parse a single JSON object of Message type * //from ww w .j a v a 2 s . c om * @param json * @param image * @param voice * @return * @throws SpikaException * @throws JSONException * @throws IOException * @throws ClientProtocolException */ private static Message parseMessageObject(JSONObject json, boolean image, boolean voice, boolean video) throws ClientProtocolException, IOException, JSONException, SpikaException { Message message = new Message(); if (json == null) { return message; } if (json.has(Const.ERROR)) { appLogout(null, false, isInvalidToken(json)); return null; } try { message.setId(json.getString(Const._ID)); } catch (JSONException e) { message.setId(""); } try { message.setRev(json.getString(Const._REV)); } catch (JSONException e) { message.setRev(""); } try { message.setType(json.getString(Const.TYPE)); } catch (JSONException e) { message.setType(""); } try { message.setMessageType(json.getString(Const.MESSAGE_TYPE)); } catch (JSONException e) { message.setMessageType(""); } try { message.setMessageTargetType(json.getString(Const.MESSAGE_TARGET_TYPE)); } catch (JSONException e) { message.setMessageTargetType(""); } try { message.setBody(json.getString(Const.BODY)); } catch (JSONException e) { message.setBody(""); } try { message.setFromUserId(json.getString(Const.FROM_USER_ID)); } catch (JSONException e) { message.setFromUserId(""); } try { message.setFromUserName(json.getString(Const.FROM_USER_NAME)); } catch (JSONException e) { message.setFromUserName(""); } try { message.setToUserId(json.getString(Const.TO_USER_ID)); } catch (JSONException e) { message.setToUserId(""); } try { message.setToGroupName(json.getString(Const.TO_USER_NAME)); } catch (JSONException e) { message.setToGroupName(""); } try { message.setToGroupId(json.getString(Const.TO_GROUP_ID)); } catch (JSONException e) { message.setToGroupId(""); } try { message.setToGroupName(json.getString(Const.TO_GROUP_NAME)); } catch (JSONException e) { message.setToGroupName(""); } try { message.setCreated(json.getLong(Const.CREATED)); } catch (JSONException e) { return null; } try { message.setModified(json.getLong(Const.MODIFIED)); } catch (JSONException e) { return null; } try { message.setValid(json.getBoolean(Const.VALID)); } catch (JSONException e) { message.setValid(true); } try { message.setAttachments(json.getJSONObject(Const.ATTACHMENTS).toString()); } catch (JSONException e) { message.setAttachments(""); } try { message.setLatitude(json.getString(Const.LATITUDE)); } catch (JSONException e) { message.setLatitude(""); } try { message.setLongitude(json.getString(Const.LONGITUDE)); } catch (JSONException e) { message.setLongitude(""); } try { message.setImageFileId((json.getString(Const.PICTURE_FILE_ID))); } catch (JSONException e) { message.setImageFileId(""); } try { message.setImageThumbFileId((json.getString(Const.PICTURE_THUMB_FILE_ID))); } catch (JSONException e) { message.setImageThumbFileId(""); } try { message.setVideoFileId((json.getString(Const.VIDEO_FILE_ID))); } catch (JSONException e) { message.setVideoFileId(""); } try { message.setVoiceFileId((json.getString(Const.VOICE_FILE_ID))); } catch (JSONException e) { message.setVoiceFileId(""); } try { message.setEmoticonImageUrl(json.getString(Const.EMOTICON_IMAGE_URL)); } catch (JSONException e) { message.setEmoticonImageUrl(""); } try { message.setAvatarFileId(json.getString(Const.AVATAR_THUMB_FILE_ID)); } catch (JSONException e) { message.setAvatarFileId(""); } try { message.setDeleteType(json.getInt(Const.DELETE_TYPE)); } catch (JSONException e) { message.setDeleteType(0); } try { message.setDelete(json.getInt(Const.DELETE_AT)); } catch (JSONException e) { message.setDelete(0); } try { message.setReadAt(json.getInt(Const.READ_AT)); } catch (JSONException e) { message.setReadAt(0); } try { message.setCommentCount(json.getInt(Const.COMMENT_COUNT)); } catch (JSONException e) { message.setCommentCount(0); } // if (image || video || voice) { // message.setCommentCount(CouchDB.getCommentCount(message.getId())); // } return message; }
From source file:com.mercandalli.android.apps.files.main.Config.java
private void load(final Context context) { final String fileContent = FileUtils.readStringFile(context, FILE_NAME); if (fileContent == null) { return;//ww w . j a v a2s . co m } try { JSONObject tmpJson = new JSONObject(fileContent); if (tmpJson.has("settings_1")) { JSONObject tmpSettings1 = tmpJson.getJSONObject("settings_1"); for (ENUM_Int enum_int : ENUM_Int.values()) { if (tmpSettings1.has(enum_int.key)) { enum_int.value = tmpSettings1.getInt(enum_int.key); } } for (ENUM_Boolean enum_boolean : ENUM_Boolean.values()) { if (tmpSettings1.has(enum_boolean.key)) { enum_boolean.value = tmpSettings1.getBoolean(enum_boolean.key); } } for (ENUM_String enum_string : ENUM_String.values()) { if (tmpSettings1.has(enum_string.key)) { enum_string.value = tmpSettings1.getString(enum_string.key); } } } } catch (JSONException e) { Log.e(getClass().getName(), "Failed to convert Json", e); } }
From source file:fr.pasteque.pos.customers.CustomerInfoExt.java
public CustomerInfoExt(JSONObject o) { super(null);//from w ww. ja va 2s . c om if (!o.isNull("id")) { this.id = o.getString("id"); } if (!o.isNull("number")) { this.taxid = o.getString("number"); } if (!o.isNull("dispName")) { this.name = o.getString("dispName"); } if (!o.isNull("key")) { this.searchkey = o.getString("key"); } if (!o.isNull("custTaxId")) { this.taxcustomerid = o.getString("custTaxId"); } if (!o.isNull("discountProfileId")) { this.discountProfileId = o.getInt("discountProfileId"); } if (!o.isNull("notes")) { this.notes = o.getString("notes"); } this.visible = o.getBoolean("visible"); if (!o.isNull("card")) { this.card = o.getString("card"); } if (!o.isNull("maxDebt")) { this.maxdebt = o.getDouble("maxDebt"); } if (!o.isNull("debtDate")) { this.curdate = DateUtils.readSecTimestamp(o.getLong("debtDate")); } if (!o.isNull("currDebt")) { this.curdebt = o.getDouble("currDebt"); } this.prepaid = o.getDouble("prepaid"); if (!o.isNull("firstName")) { this.firstname = o.getString("firstName"); } if (!o.isNull("lastName")) { this.lastname = o.getString("lastName"); } if (!o.isNull("email")) { this.email = o.getString("email"); } if (!o.isNull("phone1")) { this.phone = o.getString("phone1"); } if (!o.isNull("phone2")) { this.phone2 = o.getString("phone2"); } if (!o.isNull("fax")) { this.fax = o.getString("fax"); } if (!o.isNull("addr1")) { this.address = o.getString("addr1"); } if (!o.isNull("addr2")) { this.address2 = o.getString("addr2"); } if (!o.isNull("zipCode")) { this.postal = o.getString("zipCode"); } if (!o.isNull("city")) { this.city = o.getString("city"); } if (!o.isNull("region")) { this.region = o.getString("region"); } if (!o.isNull("country")) { this.country = o.getString("country"); } }
From source file:com.imaginary.home.cloud.device.PoweredDevice.java
static public void mapPoweredDevice(@Nonnull ControllerRelay relay, @Nonnull JSONObject json, @Nonnull Map<String, Object> state) throws JSONException { mapDevice(relay, json, state);//from ww w. jav a 2s.com state.put("deviceType", "powered"); state.put("on", json.has("on") && !json.isNull("on") && json.getBoolean("on")); }
From source file:com.gmail.at.faint545.adapters.RemoteHistoryAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { convertView = ((LayoutInflater) mContext.getSystemService(Activity.LAYOUT_INFLATER_SERVICE)) .inflate(resourceID, null); ViewHolder viewHolder = new ViewHolder(); viewHolder.name = (TextView) convertView.findViewById(R.id.remote_history_row_filename); viewHolder.status = (TextView) convertView.findViewById(R.id.remote_history_row_status); viewHolder.isChecked = (CheckBox) convertView.findViewById(R.id.remote_history_checkbox); convertView.setTag(viewHolder);//from w w w . ja v a2s . co m } JSONObject oldJob = oldJobs.get(position); if (oldJob != null) { ViewHolder viewHolder = (ViewHolder) convertView.getTag(); String jobStatus = null, jobName = null; Boolean isChecked = false; try { jobStatus = oldJob.getString(SabnzbdConstants.STATUS); jobName = oldJob.getString(SabnzbdConstants.NAME); isChecked = oldJob.getBoolean("checked"); } catch (JSONException e) { // Do nothing } if (jobStatus.equals(SabnzbdConstants.STATUS_COMPLETED)) { convertView.setBackgroundResource(R.color.light_green); } else if (jobStatus.equals(SabnzbdConstants.STATUS_FAILED)) { convertView.setBackgroundResource(R.color.light_red); } viewHolder.name.setText(jobName); viewHolder.status.setText(jobStatus); viewHolder.isChecked.setChecked(isChecked); } return convertView; }