List of usage examples for org.json JSONArray getJSONArray
public JSONArray getJSONArray(int index) throws JSONException
From source file:com.liferay.mobile.android.v7.journalarticle.JournalArticleService.java
public JSONArray getGroupArticles(long groupId, long userId, long rootFolderId, int status, boolean includeOwner, int start, int end, JSONObjectWrapper orderByComparator) throws Exception { JSONObject _command = new JSONObject(); try {/*from www . j a va2 s. c om*/ JSONObject _params = new JSONObject(); _params.put("groupId", groupId); _params.put("userId", userId); _params.put("rootFolderId", rootFolderId); _params.put("status", status); _params.put("includeOwner", includeOwner); _params.put("start", start); _params.put("end", end); mangleWrapper(_params, "orderByComparator", "com.liferay.portal.kernel.util.OrderByComparator<com.liferay.journal.model.JournalArticle>", orderByComparator); _command.put("/journal.journalarticle/get-group-articles", _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.journalarticle.JournalArticleService.java
public JSONArray getArticlesByLayoutUuid(long groupId, String layoutUuid) throws Exception { JSONObject _command = new JSONObject(); try {// w w w. j a va 2s . c om JSONObject _params = new JSONObject(); _params.put("groupId", groupId); _params.put("layoutUuid", checkNull(layoutUuid)); _command.put("/journal.journalarticle/get-articles-by-layout-uuid", _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.journalarticle.JournalArticleService.java
public JSONArray getArticlesByArticleId(long groupId, String articleId, int start, int end, JSONObjectWrapper obc) throws Exception { JSONObject _command = new JSONObject(); try {//from w ww . j a v a 2s. c o m JSONObject _params = new JSONObject(); _params.put("groupId", groupId); _params.put("articleId", checkNull(articleId)); _params.put("start", start); _params.put("end", end); mangleWrapper(_params, "obc", "com.liferay.portal.kernel.util.OrderByComparator<com.liferay.journal.model.JournalArticle>", obc); _command.put("/journal.journalarticle/get-articles-by-article-id", _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:ru.jkff.antro.ReportReader.java
public Report readReport(String filename) throws IOException { // function getProfileData() { // return (/*from www . j ava 2 s . c om*/ // JSONObject (read until {} [] braces are balanced) // ) // } // function getTrace() { // return ( // JSONObject (read until {} [] braces are balanced) // ) // } try { LineNumberReader r = new LineNumberReader( new BufferedReader(new FileReader(filename), REPORT_FILE_BUFFER_SIZE)); StringBuilder sb = new StringBuilder(); String line; while (null != (line = r.readLine())) { sb.append(line); } JSONArray data = new JSONArray(sb.toString()); JSONArray profileData = data.getJSONArray(0); JSONObject traceData = data.getJSONObject(1); return new Report(toTrace(traceData), toAnnotatedFiles(profileData)); } catch (JSONException e) { throw new RuntimeException(e); } }
From source file:twitter4j.internal.json.InternalJSONFactoryImpl.java
static GeoLocation[][] coordinatesAsGeoLocationArray(final JSONArray coordinates) throws TwitterException { try {//w ww . j a v a 2 s . c om final GeoLocation[][] boundingBox = new GeoLocation[coordinates.length()][]; for (int i = 0; i < coordinates.length(); i++) { final JSONArray array = coordinates.getJSONArray(i); boundingBox[i] = new GeoLocation[array.length()]; for (int j = 0; j < array.length(); j++) { final JSONArray coordinate = array.getJSONArray(j); boundingBox[i][j] = new GeoLocation(coordinate.getDouble(1), coordinate.getDouble(0)); } } return boundingBox; } catch (final JSONException jsone) { throw new TwitterException(jsone); } }
From source file:com.transistorsoft.cordova.bggeo.CDVBackgroundGeolocation.java
public boolean execute(String action, JSONArray data, CallbackContext callbackContext) throws JSONException { Log.d(TAG, "$ " + action + "()"); Boolean result = false;//from w w w .j a va 2s. co m if (BackgroundGeolocationService.ACTION_START.equalsIgnoreCase(action)) { result = true; if (!isStarting) { this.start(callbackContext); } else { callbackContext.error("- Waiting for previous start action to complete"); } } else if (BackgroundGeolocationService.ACTION_STOP.equalsIgnoreCase(action)) { // No implementation to stop background-tasks with Android. Just say "success" result = true; this.stop(); callbackContext.success(0); } else if (ACTION_FINISH.equalsIgnoreCase(action)) { result = true; callbackContext.success(); } else if (ACTION_ERROR.equalsIgnoreCase(action)) { result = true; this.onError(data.getString(1)); callbackContext.success(); } else if (ACTION_CONFIGURE.equalsIgnoreCase(action)) { result = true; configure(data.getJSONObject(0), callbackContext); } else if (ACTION_ADD_LOCATION_LISTENER.equalsIgnoreCase(action)) { result = true; addLocationListener(callbackContext); } else if (BackgroundGeolocationService.ACTION_CHANGE_PACE.equalsIgnoreCase(action)) { result = true; if (!isEnabled) { Log.w(TAG, "- Cannot change pace while disabled"); callbackContext.error("Cannot #changePace while disabled"); } else { changePace(callbackContext, data); } } else if (BackgroundGeolocationService.ACTION_SET_CONFIG.equalsIgnoreCase(action)) { result = true; JSONObject config = data.getJSONObject(0); setConfig(config); callbackContext.success(); } else if (ACTION_GET_STATE.equalsIgnoreCase(action)) { result = true; JSONObject state = this.getState(); PluginResult response = new PluginResult(PluginResult.Status.OK, state); response.setKeepCallback(false); callbackContext.sendPluginResult(response); } else if (ACTION_ADD_MOTION_CHANGE_LISTENER.equalsIgnoreCase(action)) { result = true; this.addMotionChangeListener(callbackContext); } else if (BackgroundGeolocationService.ACTION_GET_LOCATIONS.equalsIgnoreCase(action)) { result = true; getLocations(callbackContext); } else if (BackgroundGeolocationService.ACTION_SYNC.equalsIgnoreCase(action)) { result = true; sync(callbackContext); } else if (BackgroundGeolocationService.ACTION_GET_ODOMETER.equalsIgnoreCase(action)) { result = true; getOdometer(callbackContext); } else if (BackgroundGeolocationService.ACTION_RESET_ODOMETER.equalsIgnoreCase(action)) { result = true; resetOdometer(callbackContext); } else if (BackgroundGeolocationService.ACTION_ADD_GEOFENCE.equalsIgnoreCase(action)) { result = true; addGeofence(callbackContext, data.getJSONObject(0)); } else if (BackgroundGeolocationService.ACTION_ADD_GEOFENCES.equalsIgnoreCase(action)) { result = true; addGeofences(callbackContext, data.getJSONArray(0)); } else if (BackgroundGeolocationService.ACTION_REMOVE_GEOFENCE.equalsIgnoreCase(action)) { result = removeGeofence(data.getString(0)); if (result) { callbackContext.success(); } else { callbackContext.error("Failed to add geofence"); } } else if (BackgroundGeolocationService.ACTION_REMOVE_GEOFENCES.equalsIgnoreCase(action)) { result = removeGeofences(); if (result) { callbackContext.success(); } else { callbackContext.error("Failed to add geofence"); } } else if (BackgroundGeolocationService.ACTION_ON_GEOFENCE.equalsIgnoreCase(action)) { result = true; addGeofenceListener(callbackContext); } else if (BackgroundGeolocationService.ACTION_GET_GEOFENCES.equalsIgnoreCase(action)) { result = true; getGeofences(callbackContext); } else if (ACTION_PLAY_SOUND.equalsIgnoreCase(action)) { result = true; playSound(data.getInt(0)); callbackContext.success(); } else if (BackgroundGeolocationService.ACTION_GET_CURRENT_POSITION.equalsIgnoreCase(action)) { result = true; JSONObject options = data.getJSONObject(0); getCurrentPosition(callbackContext, options); } else if (BackgroundGeolocationService.ACTION_BEGIN_BACKGROUND_TASK.equalsIgnoreCase(action)) { // Android doesn't do background-tasks. This is an iOS thing. Just return a number. result = true; callbackContext.success(1); } else if (BackgroundGeolocationService.ACTION_CLEAR_DATABASE.equalsIgnoreCase(action)) { result = true; clearDatabase(callbackContext); } else if (ACTION_ADD_HTTP_LISTENER.equalsIgnoreCase(action)) { result = true; addHttpListener(callbackContext); } else if (ACTION_GET_LOG.equalsIgnoreCase(action)) { result = true; getLog(callbackContext); } else if (ACTION_EMAIL_LOG.equalsIgnoreCase(action)) { result = true; emailLog(callbackContext, data.getString(0)); } else if (BackgroundGeolocationService.ACTION_INSERT_LOCATION.equalsIgnoreCase(action)) { result = true; insertLocation(data.getJSONObject(0), callbackContext); } else if (BackgroundGeolocationService.ACTION_GET_COUNT.equalsIgnoreCase(action)) { result = true; getCount(callbackContext); } return result; }
From source file:com.liferay.mobile.android.v7.organization.OrganizationService.java
public JSONArray getOrganizations(long companyId, long parentOrganizationId, int start, int end) throws Exception { JSONObject _command = new JSONObject(); try {//from w w w . ja v a 2s.c om JSONObject _params = new JSONObject(); _params.put("companyId", companyId); _params.put("parentOrganizationId", parentOrganizationId); _params.put("start", start); _params.put("end", end); _command.put("/organization/get-organizations", _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.organization.OrganizationService.java
public JSONArray getOrganizations(long companyId, long parentOrganizationId) throws Exception { JSONObject _command = new JSONObject(); try {//from w w w . java2 s . c o m JSONObject _params = new JSONObject(); _params.put("companyId", companyId); _params.put("parentOrganizationId", parentOrganizationId); _command.put("/organization/get-organizations", _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.organization.OrganizationService.java
public JSONArray getUserOrganizations(long userId) throws Exception { JSONObject _command = new JSONObject(); try {/* w w w . j av a2 s . c o m*/ JSONObject _params = new JSONObject(); _params.put("userId", userId); _command.put("/organization/get-user-organizations", _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.usergroup.UserGroupService.java
public JSONArray getUserGroups(long companyId) throws Exception { JSONObject _command = new JSONObject(); try {//from www . j av a 2 s . c o m JSONObject _params = new JSONObject(); _params.put("companyId", companyId); _command.put("/usergroup/get-user-groups", _params); } catch (JSONException _je) { throw new Exception(_je); } JSONArray _result = session.invoke(_command); if (_result == null) { return null; } return _result.getJSONArray(0); }