Example #1
0
 /// <summary> Append a key. The key will be associated with the next value. In an
 /// object, every value must be preceded by a key.
 /// </summary>
 /// <param name="s">A key string.
 /// </param>
 /// <returns> this
 /// </returns>
 /// <throws>  JSONException If the key is out of place. For example, keys </throws>
 /// <summary>  do not belong in arrays or if the key is null.
 /// </summary>
 public virtual JSONWriter key(System.String s)
 {
     if (s == null)
     {
         throw new JSONException("Null key.");
     }
     if (this.mode == 'k')
     {
         try
         {
             stack[top - 1].putOnce(s, (System.Object)true);
             if (this.comma)
             {
                 this.writer.Write(',');
             }
             this.writer.Write(JSONObject.quote(s));
             this.writer.Write(':');
             this.comma = false;
             this.mode  = 'o';
             return(this);
         }
         catch (System.IO.IOException e)
         {
             throw new JSONException(e);
         }
     }
     throw new JSONException("Misplaced key.");
 }