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

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

Put or replace a String 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.
The string may be a valid JSON formatted string, in tha case, it will be trabsformed to a JSONArray, JSONObjetc or JSONNull.

index The subscript.
value A String value.
JSONException If the index is negative or if the the value is an invalid number.

Definition at line 1646 of file JSONArray.java.

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

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

Generated by  Doxygen 1.6.0   Back to index