docs: public JSONWriter key(String string) throws JSONException {
          if (string == null) {
              throw new JSONException("Null key.");
          }
          if (m_mode != 'k') {
              throw new JSONException("Misplaced key.");
          }
  
          // Throw if the key has already been seen in this scope.
          if ( ! m_scopeStack[m_top].add(string)) {
              throw new JSONException("Duplicate key \"" + string + "\"");
          }
  
          try {
              if (m_expectingComma) {
                  m_writer.write(',');
              }
              m_writer.write(JSONObject.quote(string));
              m_writer.write(':');
          }
          catch (IOException e) {
              throw new JSONException(e);
          }
          m_mode = 'o';
          m_expectingComma = false;
          return this;
      }