code: private JSONWriter end(char mode, char c) throws JSONException {
          if (this.mode != mode) {
              throw new JSONException(mode == 'a'
                  ? "Misplaced endArray."
                  : "Misplaced endObject.");
          }
          this.pop(mode);
          try {
              this.writer.write(c);
          } catch (IOException e) {
              throw new JSONException(e);
          }
          this.comma = true;
          return this;
      }
docs: End something.
  @param mode Mode
  @param c Closing character
  @return this
  @throws JSONException If unbalanced.