code: public JSONWriter key(String s) throws JSONException {
  
          if (s == null) {
              throw new JSONException("Null key.");
          }
          if (m_mode == 'k') {
              try {
                  if (m_comma) {
                      m_writer.write(',');
                  }
                  m_writer.write(JSONObject.quote(s));
                  m_writer.write(':');
                  m_comma = false;
                  m_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.<p>
  
  @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