Logo Search packages:      
Sourcecode: libjson-java version File versions

double net::sf::json::JSONArray::getDouble ( int  index  )  [inline]

Get the double value associated with an index.

Parameters:
index The index must be between 0 and size() - 1.
Returns:
The value.
Exceptions:
JSONException If the key is not found or if the value cannot be converted to a number.

Definition at line 1937 of file JSONArray.java.

Referenced by getInt(), getLong(), and optDouble().

                                        {
      Object o = get( index );
      if( o != null ){
         try{
            return o instanceof Number ? ((Number) o).doubleValue()
                  : Double.parseDouble( (String) o );
         }catch( Exception e ){
            throw new JSONException( "JSONArray[" + index + "] is not a number." );
         }
      }
      throw new JSONException( "JSONArray[" + index + "] is not a number." );
   }


Generated by  Doxygen 1.6.0   Back to index