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

JSONArray net::sf::json::JSONArray::element ( int  index,
Map  value,
JsonConfig  jsonConfig 
) [inline]

Put a value in the JSONArray, where the value will be a JSONObject which is produced from a Map.

Parameters:
index The subscript.
value The Map value.
Returns:
this.
Exceptions:
JSONException If the index is negative or if the the value is an invalid number.

Definition at line 1551 of file JSONArray.java.

References element(), elements, and size().

                                                                           {
      if( value instanceof JSONObject ){
         if( index < 0 ){
            throw new JSONException( "JSONArray[" + index + "] not found." );
         }
         if( index < size() ){
            elements.set( index, value );
         }else{
            while( index != size() ){
               element( JSONNull.getInstance() );
            }
            element( value, jsonConfig );
         }
         return this;
      }else{
         return element( index, JSONObject.fromObject( value, jsonConfig ) );
      }
   }


Generated by  Doxygen 1.6.0   Back to index