List of usage examples for org.json JSONArray getInt
public int getInt(int index) throws JSONException
From source file:salvatejero.cordova.liferay.LiferayPlugin.java
private Object[] getListOfParam(Method m, JSONArray values) throws JSONException { List<Object> listOfParams = new ArrayList<Object>(); for (int i = 0; i < m.getParameterTypes().length; i++) { @SuppressWarnings("rawtypes") Class c = m.getParameterTypes()[i]; if (c.getName().equals("java.lang.String")) { listOfParams.add(values.getString(i)); } else if (c.getName().equals("java.lang.Long")) { listOfParams.add(values.getLong(i)); } else if (c.getName().equals("java.lang.Integer")) { listOfParams.add(values.getInt(i)); } else if (c.getName().equals("long")) { listOfParams.add(values.getLong(i)); } else if (c.getName().equals("int")) { listOfParams.add(values.getInt(i)); }//from w w w. j a v a 2 s .c o m } Object[] paramsA = new Object[listOfParams.size()]; return listOfParams.toArray(paramsA); }
From source file:com.remobile.file.FileUtils.java
public boolean execute(String action, final JSONArray args, final CallbackContext callbackContext) { if (!configured) { callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, "File plugin is not configured. Please see the README.md file for details on how to update config.xml")); return true; }/*from ww w.j av a 2s . c o m*/ if (action.equals("testSaveLocationExists")) { threadhelper(new FileOp() { public void run(JSONArray args) { boolean b = DirectoryManager.testSaveLocationExists(); callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, b)); } }, args, callbackContext); } else if (action.equals("getFreeDiskSpace")) { threadhelper(new FileOp() { public void run(JSONArray args) { long l = DirectoryManager.getFreeDiskSpace(false); callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, l)); } }, args, callbackContext); } else if (action.equals("testFileExists")) { threadhelper(new FileOp() { public void run(JSONArray args) throws JSONException { String fname = args.getString(0); boolean b = DirectoryManager.testFileExists(fname); callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, b)); } }, args, callbackContext); } else if (action.equals("testDirectoryExists")) { threadhelper(new FileOp() { public void run(JSONArray args) throws JSONException { String fname = args.getString(0); boolean b = DirectoryManager.testFileExists(fname); callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, b)); } }, args, callbackContext); } else if (action.equals("readAsText")) { threadhelper(new FileOp() { public void run(JSONArray args) throws JSONException, MalformedURLException { String encoding = args.getString(1); int start = args.getInt(2); int end = args.getInt(3); String fname = args.getString(0); readFileAs(fname, start, end, callbackContext, encoding, PluginResult.MESSAGE_TYPE_STRING); } }, args, callbackContext); } else if (action.equals("readAsDataURL")) { threadhelper(new FileOp() { public void run(JSONArray args) throws JSONException, MalformedURLException { int start = args.getInt(1); int end = args.getInt(2); String fname = args.getString(0); readFileAs(fname, start, end, callbackContext, null, -1); } }, args, callbackContext); } else if (action.equals("readAsArrayBuffer")) { threadhelper(new FileOp() { public void run(JSONArray args) throws JSONException, MalformedURLException { int start = args.getInt(1); int end = args.getInt(2); String fname = args.getString(0); readFileAs(fname, start, end, callbackContext, null, PluginResult.MESSAGE_TYPE_ARRAYBUFFER); } }, args, callbackContext); } else if (action.equals("readAsBinaryString")) { threadhelper(new FileOp() { public void run(JSONArray args) throws JSONException, MalformedURLException { int start = args.getInt(1); int end = args.getInt(2); String fname = args.getString(0); readFileAs(fname, start, end, callbackContext, null, PluginResult.MESSAGE_TYPE_BINARYSTRING); } }, args, callbackContext); } else if (action.equals("write")) { threadhelper(new FileOp() { public void run(JSONArray args) throws JSONException, FileNotFoundException, IOException, NoModificationAllowedException { String fname = args.getString(0); String data = args.getString(1); int offset = args.getInt(2); Boolean isBinary = args.getBoolean(3); long fileSize = write(fname, data, offset, isBinary); callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, fileSize)); } }, args, callbackContext); } else if (action.equals("truncate")) { threadhelper(new FileOp() { public void run(JSONArray args) throws JSONException, FileNotFoundException, IOException, NoModificationAllowedException { String fname = args.getString(0); int offset = args.getInt(1); long fileSize = truncateFile(fname, offset); callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, fileSize)); } }, args, callbackContext); } else if (action.equals("requestAllFileSystems")) { threadhelper(new FileOp() { public void run(JSONArray args) throws IOException, JSONException { callbackContext.success(requestAllFileSystems()); } }, args, callbackContext); } else if (action.equals("requestAllPaths")) { cordova.getThreadPool().execute(new Runnable() { public void run() { try { callbackContext.success(requestAllPaths()); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); } else if (action.equals("requestFileSystem")) { threadhelper(new FileOp() { public void run(JSONArray args) throws IOException, JSONException { int fstype = args.getInt(0); long size = args.optLong(1); if (size != 0 && size > (DirectoryManager.getFreeDiskSpace(true) * 1024)) { callbackContext.sendPluginResult( new PluginResult(PluginResult.Status.ERROR, FileUtils.QUOTA_EXCEEDED_ERR)); } else { JSONObject obj = requestFileSystem(fstype); callbackContext.success(obj); } } }, args, callbackContext); } else if (action.equals("resolveLocalFileSystemURI")) { threadhelper(new FileOp() { public void run(JSONArray args) throws IOException, JSONException { String fname = args.getString(0); JSONObject obj = resolveLocalFileSystemURI(fname); callbackContext.success(obj); } }, args, callbackContext); } else if (action.equals("getFileMetadata")) { threadhelper(new FileOp() { public void run(JSONArray args) throws FileNotFoundException, JSONException, MalformedURLException { String fname = args.getString(0); JSONObject obj = getFileMetadata(fname); callbackContext.success(obj); } }, args, callbackContext); } else if (action.equals("getParent")) { threadhelper(new FileOp() { public void run(JSONArray args) throws JSONException, IOException { String fname = args.getString(0); JSONObject obj = getParent(fname); callbackContext.success(obj); } }, args, callbackContext); } else if (action.equals("getDirectory")) { threadhelper(new FileOp() { public void run(JSONArray args) throws FileExistsException, IOException, TypeMismatchException, EncodingException, JSONException { String dirname = args.getString(0); String path = args.getString(1); JSONObject obj = getFile(dirname, path, args.optJSONObject(2), true); callbackContext.success(obj); } }, args, callbackContext); } else if (action.equals("getFile")) { threadhelper(new FileOp() { public void run(JSONArray args) throws FileExistsException, IOException, TypeMismatchException, EncodingException, JSONException { String dirname = args.getString(0); String path = args.getString(1); JSONObject obj = getFile(dirname, path, args.optJSONObject(2), false); callbackContext.success(obj); } }, args, callbackContext); } else if (action.equals("remove")) { threadhelper(new FileOp() { public void run(JSONArray args) throws JSONException, NoModificationAllowedException, InvalidModificationException, MalformedURLException { String fname = args.getString(0); boolean success = remove(fname); if (success) { callbackContext.success(); } else { callbackContext.error(FileUtils.NO_MODIFICATION_ALLOWED_ERR); } } }, args, callbackContext); } else if (action.equals("removeRecursively")) { threadhelper(new FileOp() { public void run(JSONArray args) throws JSONException, FileExistsException, MalformedURLException, NoModificationAllowedException { String fname = args.getString(0); boolean success = removeRecursively(fname); if (success) { callbackContext.success(); } else { callbackContext.error(FileUtils.NO_MODIFICATION_ALLOWED_ERR); } } }, args, callbackContext); } else if (action.equals("moveTo")) { threadhelper(new FileOp() { public void run(JSONArray args) throws JSONException, NoModificationAllowedException, IOException, InvalidModificationException, EncodingException, FileExistsException { String fname = args.getString(0); String newParent = args.getString(1); String newName = args.getString(2); JSONObject entry = transferTo(fname, newParent, newName, true); callbackContext.success(entry); } }, args, callbackContext); } else if (action.equals("copyTo")) { threadhelper(new FileOp() { public void run(JSONArray args) throws JSONException, NoModificationAllowedException, IOException, InvalidModificationException, EncodingException, FileExistsException { String fname = args.getString(0); String newParent = args.getString(1); String newName = args.getString(2); JSONObject entry = transferTo(fname, newParent, newName, false); callbackContext.success(entry); } }, args, callbackContext); } else if (action.equals("readEntries")) { threadhelper(new FileOp() { public void run(JSONArray args) throws FileNotFoundException, JSONException, MalformedURLException { String fname = args.getString(0); JSONArray entries = readEntries(fname); callbackContext.success(entries); } }, args, callbackContext); } else if (action.equals("_getLocalFilesystemPath")) { // Internal method for testing: Get the on-disk location of a local filesystem url. // [Currently used for testing file-transfer] threadhelper(new FileOp() { public void run(JSONArray args) throws FileNotFoundException, JSONException, MalformedURLException { String localURLstr = args.getString(0); String fname = filesystemPathForURL(localURLstr); callbackContext.success(fname); } }, args, callbackContext); } else { return false; } return true; }
From source file:com.liferay.mobile.android.v7.dlfileversion.DLFileVersionService.java
public Integer getFileVersionsCount(long fileEntryId, int status) throws Exception { JSONObject _command = new JSONObject(); try {//from ww w . j av a2 s . co m JSONObject _params = new JSONObject(); _params.put("fileEntryId", fileEntryId); _params.put("status", status); _command.put("/dlfileversion/get-file-versions-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:org.billthefarmer.tuner.MainActivity.java
void getPreferences() { // Load preferences PreferenceManager.setDefaultValues(this, R.xml.preferences, false); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); // Set preferences if (audio != null) { audio.input = Integer.parseInt(preferences.getString(PREF_INPUT, "0")); audio.reference = preferences.getInt(PREF_REFERENCE, 440); audio.transpose = Integer.parseInt(preferences.getString(PREF_TRANSPOSE, "0")); audio.filter = preferences.getBoolean(PREF_FILTER, false); audio.downsample = preferences.getBoolean(PREF_DOWNSAMPLE, false); audio.multiple = preferences.getBoolean(PREF_MULTIPLE, false); audio.screen = preferences.getBoolean(PREF_SCREEN, false); audio.strobe = preferences.getBoolean(PREF_STROBE, false); audio.zoom = preferences.getBoolean(PREF_ZOOM, true); // Check screen if (audio.screen) { Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); }/*from w w w. j av a2s . c o m*/ else { Window window = getWindow(); window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } // Check for strobe before setting colours if (strobe != null) { strobe.colour = Integer.valueOf(preferences.getString(PREF_COLOUR, "0")); if (strobe.colour == 3) { JSONArray custom; try { custom = new JSONArray(preferences.getString(PREF_CUSTOM, null)); strobe.foreground = custom.getInt(0); strobe.background = custom.getInt(1); } catch (JSONException e) { e.printStackTrace(); } } // Ensure the view dimensions have been set if (strobe.width > 0 && strobe.height > 0) strobe.createShaders(); } } }
From source file:com.remcob00.cordova.youtube.YouTube.java
@Override public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { cordova.setActivityResultCallback(YouTube.this); if (action.equals("playVideo")) { if (args.length() == 2) { Intent youtubeIntent = YouTubeStandalonePlayer.createVideoIntent(cordova.getActivity(), args.getString(0), args.getString(1)); cordova.startActivityForResult(this, youtubeIntent, 2300010); return true; } else if (args.length() == 5) { Intent youtubeIntent = YouTubeStandalonePlayer.createVideoIntent(cordova.getActivity(), args.getString(0), args.getString(1), args.getInt(2), args.getBoolean(3), args.getBoolean(4)); cordova.startActivityForResult(this, youtubeIntent, 2300010); return true; } else {/* w w w. java2 s .co m*/ return false; } } else if (action.endsWith("playPlaylist")) { if (args.length() == 2) { Intent youtubeIntent = YouTubeStandalonePlayer.createPlaylistIntent(cordova.getActivity(), args.getString(0), args.getString(1)); cordova.startActivityForResult(this, youtubeIntent, 2300010); return true; } else if (args.length() == 6) { Intent youtubeIntent = YouTubeStandalonePlayer.createPlaylistIntent(cordova.getActivity(), args.getString(0), args.getString(1), args.getInt(2), args.getInt(3), args.getBoolean(4), args.getBoolean(5)); cordova.startActivityForResult(this, youtubeIntent, 2300010); return true; } else { return false; } } else if (action.endsWith("playVideos")) { List<String> videos = new ArrayList<String>(); for (int i = 0; i < args.getJSONArray(1).length(); i++) { videos.add(args.getJSONArray(1).getString(i)); } if (args.length() == 2) { Intent youtubeIntent = YouTubeStandalonePlayer.createVideosIntent(cordova.getActivity(), args.getString(0), videos); cordova.startActivityForResult(this, youtubeIntent, 2300010); return true; } else if (args.length() == 6) { Intent youtubeIntent = YouTubeStandalonePlayer.createVideosIntent(cordova.getActivity(), args.getString(0), videos, args.getInt(2), args.getInt(3), args.getBoolean(4), args.getBoolean(5)); cordova.startActivityForResult(this, youtubeIntent, 2300010); return true; } else { return false; } } return false; }
From source file:com.moodstocks.phonegap.plugin.MoodstocksPlugin.java
public void scan(JSONArray args) throws JSONException { Log.d(TAG, "scan action"); Intent scanIntent = new Intent(cordova.getActivity(), MoodstocksScanActivity.class); scanIntent.putExtra("activity", "MoodstocksScanActivity"); scanIntent.putExtra("scanOptions", args.getInt(0)); // NOTE: the original startActivityForResult() will pause PhoneGap app's js code // the one we use here is a override-version this.cordova.startActivityForResult(this, scanIntent, 1); scannerStarted = true;//from w w w . j a v a2s. com }
From source file:com.cranberrygame.phonegap.plugin.Util.java
@Override public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { PluginResult result = null;/* w w w . j av a2 s . co m*/ if (GooglePlayServicesUtil.isGooglePlayServicesAvailable(this.cordova.getActivity()) != 0) { Log.e(LOG_TAG, "Google Play Services are unavailable"); callbackContext.error("Unavailable"); return true; } else { Log.d(LOG_TAG, "** Google Play Services are available **"); } //args.length() //args.getString(0) //args.getString(1) //args.getInt(0) //args.getInt(1) //args.getBoolean(0) //args.getBoolean(1) if (action.equals("setUp")) { //Activity activity=cordova.getActivity(); //webView // final CallbackContext delayedCC = callbackContext; cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { _setUp(); PluginResult pr = new PluginResult(PluginResult.Status.OK); //pr.setKeepCallback(true); delayedCC.sendPluginResult(pr); //PluginResult pr = new PluginResult(PluginResult.Status.ERROR); //pr.setKeepCallback(true); //delayedCC.sendPluginResult(pr); } }); return true; } else if (action.equals("login")) { //Activity activity=cordova.getActivity(); //webView // loginCC = callbackContext; final CallbackContext delayedCC = callbackContext; cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { if (getGameHelper().isSignedIn()) { //PluginResult pr = new PluginResult(PluginResult.Status.OK); //pr.setKeepCallback(true); //delayedCC.sendPluginResult(pr); PluginResult pr = new PluginResult(PluginResult.Status.ERROR, "Already logged in"); //pr.setKeepCallback(true); delayedCC.sendPluginResult(pr); } else { _login(); } } }); return true; } else if (action.equals("logout")) { //Activity activity=cordova.getActivity(); //webView // final CallbackContext delayedCC = callbackContext; cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { if (getGameHelper().isSignedIn()) { _logout(); PluginResult pr = new PluginResult(PluginResult.Status.OK); //pr.setKeepCallback(true); delayedCC.sendPluginResult(pr); //PluginResult pr = new PluginResult(PluginResult.Status.ERROR); //pr.setKeepCallback(true); //delayedCC.sendPluginResult(pr); } else { //PluginResult pr = new PluginResult(PluginResult.Status.OK); //pr.setKeepCallback(true); //delayedCC.sendPluginResult(pr); PluginResult pr = new PluginResult(PluginResult.Status.ERROR, "Already logged out"); //pr.setKeepCallback(true); delayedCC.sendPluginResult(pr); } } }); return true; } else if (action.equals("getPlayerImage")) { //Activity activity=cordova.getActivity(); //webView // getPlayerImageCC = callbackContext; final CallbackContext delayedCC = callbackContext; cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { if (getGameHelper().isSignedIn()) { _getPlayerImage(); } else { //PluginResult pr = new PluginResult(PluginResult.Status.OK); //pr.setKeepCallback(true); //delayedCC.sendPluginResult(pr); PluginResult pr = new PluginResult(PluginResult.Status.ERROR, "Not logged in"); //pr.setKeepCallback(true); delayedCC.sendPluginResult(pr); } } }); return true; } else if (action.equals("getPlayerScore")) { //Activity activity=cordova.getActivity(); //webView // final String leaderboardId = args.getString(0); Log.d(LOG_TAG, String.format("%s", leaderboardId)); getPlayerScoreCC = callbackContext; final CallbackContext delayedCC = callbackContext; cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { if (getGameHelper().isSignedIn()) { _getPlayerScore(leaderboardId); } else { //PluginResult pr = new PluginResult(PluginResult.Status.OK); //pr.setKeepCallback(true); //delayedCC.sendPluginResult(pr); PluginResult pr = new PluginResult(PluginResult.Status.ERROR, "Not logged in"); //pr.setKeepCallback(true); delayedCC.sendPluginResult(pr); } } }); return true; } else if (action.equals("submitScore")) { //Activity activity=cordova.getActivity(); //webView // final String leaderboardId = args.getString(0); Log.d(LOG_TAG, String.format("%s", leaderboardId)); final int score = args.getInt(1); Log.d(LOG_TAG, String.format("%d", score)); submitScoreCC = callbackContext; final CallbackContext delayedCC = callbackContext; cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { if (getGameHelper().isSignedIn()) { _submitScore(leaderboardId, score); } else { //PluginResult pr = new PluginResult(PluginResult.Status.OK); //pr.setKeepCallback(true); //delayedCC.sendPluginResult(pr); PluginResult pr = new PluginResult(PluginResult.Status.ERROR, "Not logged in"); //pr.setKeepCallback(true); delayedCC.sendPluginResult(pr); } } }); return true; } else if (action.equals("showLeaderboard")) { //Activity activity=cordova.getActivity(); //webView // final String leaderboardId = args.getString(0); Log.d(LOG_TAG, String.format("%s", leaderboardId)); final CallbackContext delayedCC = callbackContext; cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { if (getGameHelper().isSignedIn()) { _showLeaderboard(leaderboardId); PluginResult pr = new PluginResult(PluginResult.Status.OK); //pr.setKeepCallback(true); delayedCC.sendPluginResult(pr); //PluginResult pr = new PluginResult(PluginResult.Status.ERROR); //pr.setKeepCallback(true); //delayedCC.sendPluginResult(pr); } else { //PluginResult pr = new PluginResult(PluginResult.Status.OK); //pr.setKeepCallback(true); //delayedCC.sendPluginResult(pr); PluginResult pr = new PluginResult(PluginResult.Status.ERROR, "Not logged in"); //pr.setKeepCallback(true); delayedCC.sendPluginResult(pr); } } }); return true; } else if (action.equals("unlockAchievement")) { //Activity activity=cordova.getActivity(); //webView // final String achievementId = args.getString(0); Log.d(LOG_TAG, String.format("%s", achievementId)); unlockAchievementCC = callbackContext; final CallbackContext delayedCC = callbackContext; cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { if (getGameHelper().isSignedIn()) { _unlockAchievement(achievementId); } else { //PluginResult pr = new PluginResult(PluginResult.Status.OK); //pr.setKeepCallback(true); //delayedCC.sendPluginResult(pr); PluginResult pr = new PluginResult(PluginResult.Status.ERROR, "Not logged in"); //pr.setKeepCallback(true); delayedCC.sendPluginResult(pr); } } }); return true; } else if (action.equals("incrementAchievement")) { //Activity activity=cordova.getActivity(); //webView // final String achievementId = args.getString(0); Log.d(LOG_TAG, String.format("%s", achievementId)); final int stepsOrPercent = args.getInt(1); Log.d(LOG_TAG, String.format("%d", stepsOrPercent)); incrementAchievementCC = callbackContext; final CallbackContext delayedCC = callbackContext; cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { if (getGameHelper().isSignedIn()) { _incrementAchievement(achievementId, stepsOrPercent); } else { //PluginResult pr = new PluginResult(PluginResult.Status.OK); //pr.setKeepCallback(true); //delayedCC.sendPluginResult(pr); PluginResult pr = new PluginResult(PluginResult.Status.ERROR, "Not logged in"); //pr.setKeepCallback(true); delayedCC.sendPluginResult(pr); } } }); return true; } else if (action.equals("showAchievements")) { //Activity activity=cordova.getActivity(); //webView // final CallbackContext delayedCC = callbackContext; cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { if (getGameHelper().isSignedIn()) { _showAchievements(); PluginResult pr = new PluginResult(PluginResult.Status.OK); //pr.setKeepCallback(true); delayedCC.sendPluginResult(pr); //PluginResult pr = new PluginResult(PluginResult.Status.ERROR); //pr.setKeepCallback(true); //delayedCC.sendPluginResult(pr); } else { //PluginResult pr = new PluginResult(PluginResult.Status.OK); //pr.setKeepCallback(true); //delayedCC.sendPluginResult(pr); PluginResult pr = new PluginResult(PluginResult.Status.ERROR, "Not logged in"); //pr.setKeepCallback(true); delayedCC.sendPluginResult(pr); } } }); return true; } else if (action.equals("resetAchievements")) { //Activity activity=cordova.getActivity(); //webView // final CallbackContext delayedCC = callbackContext; cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { _resetAchievements(); PluginResult pr = new PluginResult(PluginResult.Status.OK); //pr.setKeepCallback(true); delayedCC.sendPluginResult(pr); //PluginResult pr = new PluginResult(PluginResult.Status.ERROR); //pr.setKeepCallback(true); //delayedCC.sendPluginResult(pr); } }); return true; } return false; // Returning false results in a "MethodNotFound" error. }
From source file:src.Parser.java
public static void main(String[] args) throws JSONException { HttpQuery http = new HttpQuery(); String response = ""; try {//from w ww. ja va 2 s . com response = http.send( "http://router.project-osrm.org/viaroute?loc=50.4423,30.5298&loc=50.4433,30.5151&z=0&instructions=true&geometry=false"); } catch (Exception ex) { Logger.getLogger(Parser.class.getName()).log(Level.SEVERE, null, ex); } JSONObject obj = new JSONObject(response); JSONArray arr = obj.getJSONArray("route_instructions"); JSONArray arr2; for (int i = 0; i < arr.length(); i++) { arr2 = arr.getJSONArray(i); String str = arr2.getString(0) + ", " + arr2.getString(1) + ", " + arr2.getInt(2) + ", " + arr2.getInt(3) + ", " + arr2.getInt(4); System.out.println(str); System.out.println(); } System.out.println(); System.out.println(response); }
From source file:org.rssin.serialization.JsonSerializer.java
public static List<Integer> integersListFromJson(JSONArray json) throws JSONException { List<Integer> list = new ArrayList<>(); for (int i = 0; i < json.length(); i++) { list.add(json.getInt(i)); }//from www. j av a 2 s . c om return list; }
From source file:oculus.aperture.common.JSONProperties.java
@Override public Iterable<Integer> getIntegers(String key) { try {//from w w w . ja v a 2 s . c o m final JSONArray array = obj.getJSONArray(key); return new Iterable<Integer>() { @Override public Iterator<Integer> iterator() { return new Iterator<Integer>() { private final int n = array.length(); private int i = 0; @Override public boolean hasNext() { return n > i; } @Override public Integer next() { try { return (n > i) ? array.getInt(i++) : null; } catch (JSONException e) { return null; } } @Override public void remove() { throw new UnsupportedOperationException(); } }; } }; } catch (JSONException e) { return EmptyIterable.instance(); } }