code: public JSONArray element( int index, Object value, JsonConfig jsonConfig ) {
        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;
     }
docs: 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.
  
  @param index The subscript.
  @param value An object value. The value should be a Boolean, Double,
  Integer, JSONArray, JSONObject, JSONFunction, Long, String,
  JSONString or the JSONNull object.
  @return this.
  @throws JSONException If the index is negative or if the the value is an
  invalid number.