code: public JSONBuilder key( String s ) {
        if( s == null ){
           throw new JSONException( "Null key." );
        }
        if( this.mode == 'k' ){
           try{
              if( this.comma ){
                 this.writer.write( ',' );
              }
              this.writer.write( JSONUtils.quote( s ) );
              this.writer.write( ':' );
              this.comma = false;
              this.mode = 'o';
              return this;
           }catch( IOException e ){
              throw new JSONException( e );
           }
        }
        throw new JSONException( "Misplaced key." );
     }
docs: Append a key. The key will be associated with the next value. In an
  object, every value must be preceded by a key.
  
  @param s A key string.
  @return this
  @throws JSONException If the key is out of place. For example, keys do not
  belong in arrays or if the key is null.