/** * Get a value from an index as a float. JSON uses 'double' values * internally, so this is simply getDouble() cast to a float. * * @webref jsonarray:method * @brief Gets the float value associated with an index * @param index must be between 0 and length() - 1 * @see JSONArray#getInt(int) * @see JSONArray#getString(int) * @see JSONArray#getBoolean(int) */ public float getFloat(int index) { return (float) getDouble(index); }
/** * Get a value from an index as a float. JSON uses 'double' values * internally, so this is simply getDouble() cast to a float. * * @webref jsonarray:method * @brief Gets the float value associated with an index * @param index must be between 0 and length() - 1 * @see JSONArray#getInt(int) * @see JSONArray#getString(int) * @see JSONArray#getBoolean(int) */ public float getFloat(int index) { return (float) getDouble(index); }
/** * Get the optional double 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 subscript * @param defaultValue The default value. * @return The value. */ public double getDouble(int index, double defaultValue) { try { return this.getDouble(index); } catch (Exception e) { return defaultValue; } }
/** * Get the optional double 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 subscript * @param defaultValue The default value. * @return The value. */ public double getDouble(int index, double defaultValue) { try { return this.getDouble(index); } catch (Exception e) { return defaultValue; } }
/** Get this entire array as a double array. Everything must be an double. */ public double[] getDoubleArray() { double[] outgoing = new double[size()]; for (int i = 0; i < size(); i++) { outgoing[i] = getDouble(i); } return outgoing; }
/** Get this entire array as a double array. Everything must be an double. */ public double[] getDoubleArray() { double[] outgoing = new double[size()]; for (int i = 0; i < size(); i++) { outgoing[i] = getDouble(i); } return outgoing; }