List of usage examples for org.json JSONArray getJSONObject
public JSONObject getJSONObject(int index) throws JSONException
From source file:com.liferay.mobile.android.v7.journalfolder.JournalFolderService.java
public JSONObject moveFolder(long folderId, long parentFolderId, JSONObjectWrapper serviceContext) throws Exception { JSONObject _command = new JSONObject(); try {/*from w w w . j av a 2s . c o m*/ JSONObject _params = new JSONObject(); _params.put("folderId", folderId); _params.put("parentFolderId", parentFolderId); mangleWrapper(_params, "serviceContext", "com.liferay.portal.kernel.service.ServiceContext", serviceContext); _command.put("/journal.journalfolder/move-folder", _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.v7.journalfolder.JournalFolderService.java
public JSONObject updateFolder(long groupId, long folderId, long parentFolderId, String name, String description, boolean mergeWithParentFolder, JSONObjectWrapper serviceContext) throws Exception { JSONObject _command = new JSONObject(); try {/* ww w . ja v a 2 s .c o m*/ JSONObject _params = new JSONObject(); _params.put("groupId", groupId); _params.put("folderId", folderId); _params.put("parentFolderId", parentFolderId); _params.put("name", checkNull(name)); _params.put("description", checkNull(description)); _params.put("mergeWithParentFolder", mergeWithParentFolder); mangleWrapper(_params, "serviceContext", "com.liferay.portal.kernel.service.ServiceContext", serviceContext); _command.put("/journal.journalfolder/update-folder", _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.v7.journalfolder.JournalFolderService.java
public JSONObject updateFolder(long groupId, long folderId, long parentFolderId, String name, String description, JSONArray ddmStructureIds, int restrictionType, boolean mergeWithParentFolder, JSONObjectWrapper serviceContext) throws Exception { JSONObject _command = new JSONObject(); try {//from ww w. j av a 2 s . c o m JSONObject _params = new JSONObject(); _params.put("groupId", groupId); _params.put("folderId", folderId); _params.put("parentFolderId", parentFolderId); _params.put("name", checkNull(name)); _params.put("description", checkNull(description)); _params.put("ddmStructureIds", checkNull(ddmStructureIds)); _params.put("restrictionType", restrictionType); _params.put("mergeWithParentFolder", mergeWithParentFolder); mangleWrapper(_params, "serviceContext", "com.liferay.portal.kernel.service.ServiceContext", serviceContext); _command.put("/journal.journalfolder/update-folder", _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.v7.journalfolder.JournalFolderService.java
public JSONObject moveFolderFromTrash(long folderId, long parentFolderId, JSONObjectWrapper serviceContext) throws Exception { JSONObject _command = new JSONObject(); try {/* w ww .j ava2 s . co m*/ JSONObject _params = new JSONObject(); _params.put("folderId", folderId); _params.put("parentFolderId", parentFolderId); mangleWrapper(_params, "serviceContext", "com.liferay.portal.kernel.service.ServiceContext", serviceContext); _command.put("/journal.journalfolder/move-folder-from-trash", _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.v7.journalfolder.JournalFolderService.java
public JSONObject moveFolderToTrash(long folderId) throws Exception { JSONObject _command = new JSONObject(); try {//w w w . ja v a 2s. co m JSONObject _params = new JSONObject(); _params.put("folderId", folderId); _command.put("/journal.journalfolder/move-folder-to-trash", _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.v7.journalfolder.JournalFolderService.java
public JSONObject addFolder(long groupId, long parentFolderId, String name, String description, JSONObjectWrapper serviceContext) throws Exception { JSONObject _command = new JSONObject(); try {// w w w .j a v a 2 s . c om JSONObject _params = new JSONObject(); _params.put("groupId", groupId); _params.put("parentFolderId", parentFolderId); _params.put("name", checkNull(name)); _params.put("description", checkNull(description)); mangleWrapper(_params, "serviceContext", "com.liferay.portal.kernel.service.ServiceContext", serviceContext); _command.put("/journal.journalfolder/add-folder", _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.v7.journalfolder.JournalFolderService.java
public JSONObject fetchFolder(long folderId) throws Exception { JSONObject _command = new JSONObject(); try {/*from w ww .j av a2s.c o m*/ JSONObject _params = new JSONObject(); _params.put("folderId", folderId); _command.put("/journal.journalfolder/fetch-folder", _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.streaming.sweetplayer.fragment.TopFragment.java
private void getTopList() { JSONParser jsonParser = new JSONParser(); JSONArray jsonArray; try {/* ww w . ja va 2s . co m*/ JSONObject json = jsonParser.getJSONFromUrl(Config.TOP_URL); if (json != null) { jsonArray = json.getJSONArray(Config.SONGS_ITEM); int array_length = jsonArray.length(); if (array_length > 0) { for (int i = 0; i < array_length; i++) { HashMap<String, String> map = new HashMap<String, String>(); JSONObject jsonObject = jsonArray.getJSONObject(i); map.put(Config.ID, jsonObject.getString(Config.ID)); map.put(Config.ARTIST, jsonObject.getString(Config.ARTIST)); map.put(Config.NAME, jsonObject.getString(Config.SONG)); map.put(Config.MP3, jsonObject.getString(Config.MP3)); map.put(Config.DURATION, jsonObject.getString(Config.DURATION)); map.put(Config.URL, jsonObject.getString(Config.URL)); map.put(Config.IMAGE, jsonObject.getString(Config.IMAGE)); mTopList.add(map); } } else { // Showing a message should be done in the UI thread. mActivity.runOnUiThread(new Runnable() { public void run() { Utils.showUserMessage(mActivity.getApplicationContext(), mActivity.getString(R.string.search_empty)); } }); } } } catch (JSONException e) { e.printStackTrace(); } }
From source file:org.indigo.cdmi.backend.radosgw.JsonResponseTranlator.java
/** * Making use of String in JSON format, creates list of BackedCapability objects * related to each QoS profile described in passed JSON. * //from ww w . j av a2s . c o m * @see GatewayResponseTranslator#getBackendCapabilitiesList(String) */ @Override public List<BackendCapability> getBackendCapabilitiesList(String gatewayResponse) { List<BackendCapability> backendCapabilities = new ArrayList<>(); /* * check input parameters sanity conditions */ if (gatewayResponse == null) { log.error("Argument of name input cannot be null"); throw new IllegalArgumentException("input argument cannot be null"); } /* * convert response from string to JSONArray representation and from * now on treat this object as data model for further processing */ JSONArray backendProfilesArray = new JSONArray(gatewayResponse); log.debug("JSONArray:", backendProfilesArray); /* * iterate over all profiles described by backendProfilesArray, * and for each profile create related BackedndCapability object */ for (int i = 0; i < backendProfilesArray.length(); i++) { JSONObject profileAsJsonObj = backendProfilesArray.getJSONObject(i); log.debug("JSONObject: {}", profileAsJsonObj); BackendCapability backendCapability = createBackedCapability(profileAsJsonObj); log.debug("Created BackendCapability: {}", backendCapability); backendCapabilities.add(backendCapability); } // for() return backendCapabilities; }
From source file:com.intel.xdk.device.Device.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 when the action was valid, false otherwise. *///w w w.ja va 2s . c o m public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { if (action.equals("openWebPage")) { this.openWebPage(args.getString(0)); } else if (action.equals("getRemoteData")) { //String success = args.getString(3); //String error = args.getString(4); if (args.length() <= 3) { getRemoteData(args.getString(0), args.getString(1), args.getString(2), callbackContext); } else { getRemoteData(args.getString(0), args.getString(1), args.getString(2), args.getString(3), args.getString(4)); } } else if (action.equals("getRemoteDataExt")) { final JSONObject json = args.getJSONObject(0); cordova.getThreadPool().execute(new Runnable() { @Override public void run() { Device.this.getRemoteDataExt(json); } }); } else if (action.equals("getRemoteDataWithID")) { String success = args.getString(4); String error = args.getString(5); if (success == "null" && error == "null") { this.getRemoteDataWithID(args.getString(0), args.getString(1), args.getString(2), args.getInt(3), callbackContext); } else { this.getRemoteDataWithID(args.getString(0), args.getString(1), args.getString(2), args.getInt(3), args.getString(4), args.getString(5)); } } else if (action.equals("hideStatusBar")) { this.hideStatusBar(); } else if (action.equals("launchExternal")) { this.launchExternal(args.getString(0)); } else if (action.equals("managePower")) { this.managePower(args.getBoolean(0), args.getBoolean(1)); } else if (action.equals("runInstallNativeApp")) { this.runInstallNativeApp(args.getString(0), args.getString(1), args.getString(2), args.getString(3)); } else if (action.equals("sendEmail")) { this.sendEmail(args.getString(0), args.getString(1), args.getString(2), args.getBoolean(3), args.getString(4), args.getString(5)); } else if (action.equals("sendSMS")) { this.sendSMS(args.getString(0), args.getString(1)); } else if (action.equals("setAutoRotate")) { this.setAutoRotate(args.getBoolean(0)); } else if (action.equals("setRotateOrientation")) { this.setRotateOrientation(args.getString(0)); } else if (action.equals("setBasicAuthentication")) { this.setBasicAuthentication(args.getString(0), args.getString(1), args.getString(2)); } else if (action.equals("showRemoteSite")) { this.showRemoteSite(args.getString(0), args.getInt(1), args.getInt(2), args.getInt(3), args.getInt(4)); } else if (action.equals("showRemoteSiteExt")) { this.showRemoteSite(args.getString(0), args.getInt(1), args.getInt(2), args.getInt(3), args.getInt(4), args.getInt(5), args.getInt(6)); } else if (action.equals("closeRemoteSite")) { this.closeRemoteSite(); } else if (action.equals("updateConnection")) { this.updateConnection(); } else if (action.equals("mainViewExecute")) { this.mainViewExecute(args.getString(0)); } else if (action.equals("copyToClipboard")) { this.copyToClipboard(args.getString(0)); } else if (action.equals("initialize")) { this.initialize(); } else { return false; } // All actions are async. //callbackContext.success(); return true; }