List of usage examples for org.json JSONObject put
public JSONObject put(String key, Object value) throws JSONException
From source file:sh.calaba.driver.server.CalabashProxy.java
public JSONArray getAllSessionDetails() { JSONArray sessions = new JSONArray(); if (!sessionConnectors.isEmpty()) { for (Map.Entry<String, CalabashAndroidConnector> entry : sessionConnectors.entrySet()) { JSONObject jsonEntry = new JSONObject(); try { jsonEntry.put("id", entry.getKey()); jsonEntry.put("capabilities", new JSONObject(entry.getValue().getSessionCapabilities().getRawCapabilities())); sessions.put(jsonEntry); } catch (JSONException e) { throw new CalabashException("Error occured while JSON handling: ", e); }//w w w. j a v a 2 s. com } } return sessions; }
From source file:com.zeroone_creative.basicapplication.view.activity.WelcomeActivity.java
@Click(R.id.welcome_imagebutton_register) void clickRegist() { findViewById(R.id.welcome_imagebutton_register).setEnabled(false); JSONRequestUtil createUserRequest = new JSONRequestUtil(new NetworkTaskCallback() { @Override/* w w w . j a va 2 s .com*/ public void onSuccessNetworkTask(int taskId, Object object) { mContext.getSharedPreferences(AppConfig.PREF_NAME, Context.MODE_PRIVATE).edit() .putString(AppConfig.PREF_KEY_USER, object.toString()).commit(); RegistActivity_.intent(mContext).start(); } @Override public void onFailedNetworkTask(int taskId, Object object) { Toast.makeText(mContext, getString(R.string.common_faild_network), Toast.LENGTH_SHORT).show(); } }, this.getClass().getSimpleName(), null); JSONObject params = new JSONObject(); try { params.put("name", mUserIdEditText.getText().toString()); } catch (JSONException e) { e.printStackTrace(); } createUserRequest.onRequest(VolleyHelper.getRequestQueue(this), Request.Priority.HIGH, UriUtil.postCreateUser(), NetworkTasks.Createuser, params); }
From source file:edu.umass.cs.gigapaxos.paxospackets.AcceptPacket.java
@Override public JSONObject toJSONObjectImpl() throws JSONException { JSONObject json = super.toJSONObjectImpl(); json.put(PaxosPacket.NodeIDKeys.SNDR.toString(), sender); return json;//from w w w .ja va 2 s . c om }
From source file:edu.umass.cs.gigapaxos.paxospackets.AcceptPacket.java
@Override public net.minidev.json.JSONObject toJSONSmartImpl() throws JSONException { net.minidev.json.JSONObject json = super.toJSONSmartImpl(); json.put(PaxosPacket.NodeIDKeys.SNDR.toString(), sender); return json;/* w w w.j av a2 s. c o m*/ }
From source file:com.joyfulmongo.db.OpCmdAdd.java
@Override public void onCreate(String colname, JSONObject parseObject) { JSONArray a = mObj.optJSONArray(AddProps.objects.toString()); parseObject.put(key, a); }
From source file:com.joyfulmongo.db.OpCmdAdd.java
@Override public void onUpdate(String colname, JSONObject parseObject) { JSONArray a = mObj.optJSONArray(AddProps.objects.toString()); JSONObject each = new JSONObject(); each.put(CMD_EACH, a); JSONObject addToSet = parseObject.optJSONObject(CMD_ADD_TO_SET); if (addToSet == null) { JSONObject field = new JSONObject(); field.put(key, each);// w w w. j av a 2 s .c o m parseObject.remove(key); parseObject.put(CMD_ADD_TO_SET, field); } else { parseObject.remove(key); addToSet.put(key, each); } }
From source file:com.liferay.mobile.android.v62.contact.ContactService.java
public JSONObject getContact(long contactId) throws Exception { JSONObject _command = new JSONObject(); try {//from w ww .j a v a 2 s .com JSONObject _params = new JSONObject(); _params.put("contactId", contactId); _command.put("/contact/get-contact", _params); } catch (JSONException _je) { throw new Exception(_je); } JSONArray _result = session.invoke(_command); if (_result == null) { return null; } return _result.getJSONObject(0); }
From source file:com.liferay.mobile.android.v62.contact.ContactService.java
public JSONArray getContacts(long classNameId, long classPK, int start, int end, JSONObjectWrapper orderByComparator) throws Exception { JSONObject _command = new JSONObject(); try {//www . j a v a2s .c o m JSONObject _params = new JSONObject(); _params.put("classNameId", classNameId); _params.put("classPK", classPK); _params.put("start", start); _params.put("end", end); mangleWrapper(_params, "orderByComparator", "com.liferay.portal.kernel.util.OrderByComparator", orderByComparator); _command.put("/contact/get-contacts", _params); } catch (JSONException _je) { throw new Exception(_je); } JSONArray _result = session.invoke(_command); if (_result == null) { return null; } return _result.getJSONArray(0); }
From source file:com.liferay.mobile.android.v62.contact.ContactService.java
public Integer getContactsCount(long classNameId, long classPK) throws Exception { JSONObject _command = new JSONObject(); try {//from ww w . j a v a2 s . c o m JSONObject _params = new JSONObject(); _params.put("classNameId", classNameId); _params.put("classPK", classPK); _command.put("/contact/get-contacts-count", _params); } catch (JSONException _je) { throw new Exception(_je); } JSONArray _result = session.invoke(_command); if (_result == null) { return null; } return _result.getInt(0); }
From source file:com.polyvi.xface.extension.advancedfiletransfer.XFileUploader.java
@Override public void onError(int errorCode) { setState(INIT);//from w ww .ja v a2 s .c om JSONObject error = new JSONObject(); Status status = Status.ERROR; try { error.put("code", errorCode); error.put("source", mFilePath); error.put("target", mServer); } catch (JSONException e) { status = Status.JSON_EXCEPTION; XLog.e(CLASS_NAME, e.getMessage()); } XExtensionResult result = new XExtensionResult(status, error); mCallbackCtx.sendExtensionResult(result); }