code: private JsonWriter close(int empty, int nonempty, String closeBracket)
        throws IOException {
      int context = peek();
      if (context != nonempty && context != empty) {
        throw new IllegalStateException("Nesting problem.");
      }
      if (deferredName != null) {
        throw new IllegalStateException("Dangling name: " + deferredName);
      }
  
      stackSize--;
      if (context == nonempty) {
        newline();
      }
      out.write(closeBracket);
      return this;
    }
docs: Closes the current scope by appending any necessary whitespace and the
  given bracket.