code: private void writeJsonObjectEnd() throws TException {
          try {
              getCurrentWriter().writeEndObject();
              popContext();
              if (getCurrentContext().isMapKey()) {
                  final String writerString = getWriterString();
                  popWriter();
                  getCurrentWriter().writeFieldName(writerString);
              }
  
              // flush at the end of the final struct.
              if (1 == contextStack.size()) {
                  getCurrentWriter().flush();
              }
          } catch (IOException ex) {
              throw new TException(ex);
          }
      }
docs: Helper to write out the end of a Thrift type (either struct or map),
  both of which are written as JsonObjects.