/** * Get the optional int value associated with an index. * The defaultValue is returned if there is no value for the index, * or if the value is not a number and cannot be converted to a number. * @param index The index must be between 0 and length() - 1. * @param defaultValue The default value. * @return The value. */ public int getInt(int index, int defaultValue) { try { return getInt(index); } catch (Exception e) { return defaultValue; } }
/** * Get the optional int value associated with an index. * The defaultValue is returned if there is no value for the index, * or if the value is not a number and cannot be converted to a number. * @param index The index must be between 0 and length() - 1. * @param defaultValue The default value. * @return The value. */ public int getInt(int index, int defaultValue) { try { return getInt(index); } catch (Exception e) { return defaultValue; } }
/** * Get this entire array as an int array. Everything must be an int. * * @webref jsonarray:method * @brief Gets the entire array as array of ints * @see JSONArray#getStringArray() */ public int[] getIntArray() { int[] outgoing = new int[size()]; for (int i = 0; i < size(); i++) { outgoing[i] = getInt(i); } return outgoing; }
/** * Get this entire array as an int array. Everything must be an int. * * @webref jsonarray:method * @brief Gets the entire array as array of ints * @see JSONArray#getStringArray() */ public int[] getIntArray() { int[] outgoing = new int[size()]; for (int i = 0; i < size(); i++) { outgoing[i] = getInt(i); } return outgoing; }