List of usage examples for org.json JSONArray getJSONArray
public JSONArray getJSONArray(int index) throws JSONException
From source file:com.liferay.mobile.android.v7.assetvocabulary.AssetVocabularyService.java
public JSONArray getGroupVocabularies(long groupId, boolean createDefaultVocabulary, int start, int end, JSONObjectWrapper obc) throws Exception { JSONObject _command = new JSONObject(); try {/*from w ww . java2s. co m*/ JSONObject _params = new JSONObject(); _params.put("groupId", groupId); _params.put("createDefaultVocabulary", createDefaultVocabulary); _params.put("start", start); _params.put("end", end); mangleWrapper(_params, "obc", "com.liferay.portal.kernel.util.OrderByComparator<com.liferay.asset.kernel.model.AssetVocabulary>", obc); _command.put("/assetvocabulary/get-group-vocabularies", _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.v7.assetvocabulary.AssetVocabularyService.java
public JSONArray getGroupVocabularies(long groupId, int start, int end, JSONObjectWrapper obc) throws Exception { JSONObject _command = new JSONObject(); try {//from w ww . j a v a 2s. co m JSONObject _params = new JSONObject(); _params.put("groupId", groupId); _params.put("start", start); _params.put("end", end); mangleWrapper(_params, "obc", "com.liferay.portal.kernel.util.OrderByComparator<com.liferay.asset.kernel.model.AssetVocabulary>", obc); _command.put("/assetvocabulary/get-group-vocabularies", _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.v7.assetvocabulary.AssetVocabularyService.java
public JSONArray getGroupVocabularies(long groupId, String name, int start, int end, JSONObjectWrapper obc) throws Exception { JSONObject _command = new JSONObject(); try {//from w ww .j a v a 2 s . co m JSONObject _params = new JSONObject(); _params.put("groupId", groupId); _params.put("name", checkNull(name)); _params.put("start", start); _params.put("end", end); mangleWrapper(_params, "obc", "com.liferay.portal.kernel.util.OrderByComparator<com.liferay.asset.kernel.model.AssetVocabulary>", obc); _command.put("/assetvocabulary/get-group-vocabularies", _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.v7.assetvocabulary.AssetVocabularyService.java
public JSONArray getGroupVocabularies(JSONArray groupIds) throws Exception { JSONObject _command = new JSONObject(); try {//from w w w. j a v a 2 s.c om JSONObject _params = new JSONObject(); _params.put("groupIds", checkNull(groupIds)); _command.put("/assetvocabulary/get-group-vocabularies", _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.v7.assetvocabulary.AssetVocabularyService.java
public JSONArray getGroupVocabularies(long groupId, boolean createDefaultVocabulary) throws Exception { JSONObject _command = new JSONObject(); try {/*from w ww . ja v a2s. c o m*/ JSONObject _params = new JSONObject(); _params.put("groupId", groupId); _params.put("createDefaultVocabulary", createDefaultVocabulary); _command.put("/assetvocabulary/get-group-vocabularies", _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.v7.assetvocabulary.AssetVocabularyService.java
public JSONArray getGroupVocabularies(long groupId) throws Exception { JSONObject _command = new JSONObject(); try {/*from w w w .jav a 2 s . c om*/ JSONObject _params = new JSONObject(); _params.put("groupId", groupId); _command.put("/assetvocabulary/get-group-vocabularies", _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.v7.assetvocabulary.AssetVocabularyService.java
public JSONArray getVocabularies(JSONArray vocabularyIds) throws Exception { JSONObject _command = new JSONObject(); try {// w ww. jav a 2 s. c o m JSONObject _params = new JSONObject(); _params.put("vocabularyIds", checkNull(vocabularyIds)); _command.put("/assetvocabulary/get-vocabularies", _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:org.apache.cordova.contacts.ContactManager.java
/** * Executes the request and returns PluginResult. * * @param action The action to execute. * @param args JSONArray of arguments for the plugin. * @param callbackContext The callback context used when calling back into JavaScript. * @return True if the action was valid, false otherwise. *//*from w w w . j a v a2s.c om*/ public boolean execute(String action, JSONArray args, final CallbackContext callbackContext) throws JSONException { this.callbackContext = callbackContext; this.executeArgs = args; /** * Check to see if we are on an Android 1.X device. If we are return an error as we * do not support this as of Cordova 1.0. */ if (android.os.Build.VERSION.RELEASE.startsWith("1.")) { callbackContext.sendPluginResult( new PluginResult(PluginResult.Status.ERROR, ContactManager.NOT_SUPPORTED_ERROR)); return true; } /** * Only create the contactAccessor after we check the Android version or the program will crash * older phones. */ if (this.contactAccessor == null) { this.contactAccessor = new ContactAccessorSdk5(this.cordova); } if (action.equals("search")) { final JSONArray filter = args.getJSONArray(0); final JSONObject options = args.get(1) == null ? null : args.getJSONObject(1); this.cordova.getThreadPool().execute(new Runnable() { public void run() { JSONArray res = contactAccessor.search(filter, options); callbackContext.success(res); } }); } else if (action.equals("save")) { final JSONObject contact = args.getJSONObject(0); this.cordova.getThreadPool().execute(new Runnable() { public void run() { JSONObject res = null; String id = contactAccessor.save(contact); if (id != null) { try { res = contactAccessor.getContactById(id); } catch (JSONException e) { Log.e(LOG_TAG, "JSON fail.", e); } } if (res != null) { callbackContext.success(res); } else { callbackContext .sendPluginResult(new PluginResult(PluginResult.Status.ERROR, UNKNOWN_ERROR)); } } }); } else if (action.equals("remove")) { final String contactId = args.getString(0); this.cordova.getThreadPool().execute(new Runnable() { public void run() { if (contactAccessor.remove(contactId)) { callbackContext.success(); } else { callbackContext .sendPluginResult(new PluginResult(PluginResult.Status.ERROR, UNKNOWN_ERROR)); } } }); } else if (action.equals("pickContact")) { pickContactAsync(); } else { return false; } return true; }
From source file:com.liferay.mobile.android.v7.mdrrulegroup.MDRRuleGroupService.java
public JSONArray getRuleGroups(JSONArray groupIds, int start, int end) throws Exception { JSONObject _command = new JSONObject(); try {/*from w w w. j av a 2 s . co m*/ JSONObject _params = new JSONObject(); _params.put("groupIds", checkNull(groupIds)); _params.put("start", start); _params.put("end", end); _command.put("/mdr.mdrrulegroup/get-rule-groups", _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.dubsar_dictionary.Dubsar.model.Autocompleter.java
@Override public void parseData(Object jsonResponse) throws JSONException { /*//w w w. j a va 2s .c o m * Expect data like [ "term", [ "result1", "result2", ... "result10" ] ] * (based on the OpenSearch protocol) */ JSONArray response = (JSONArray) jsonResponse; JSONArray list = response.getJSONArray(1); mResults = new ArrayList<String>(list.length()); for (int j = 0; j < list.length(); ++j) { mResults.add(list.getString(j)); } }