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

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

Put or replace an object value in the JSONArray. If the index is greater than the length of the JSONArray, then null elements will be added as necessary to pad it out.

Parameters:
index The subscript.
value An object value. The value should be a Boolean, Double, Integer, JSONArray, JSONObject, JSONFunction, Long, String, JSONString or the JSONNull object.
Returns:
this.
Exceptions:
JSONException If the index is negative or if the the value is an invalid number.

Definition at line 1600 of file JSONArray.java.

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

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


Generated by  Doxygen 1.6.0   Back to index