code: private <T> void writeNameOrValue(TypedParser<T> helper, T val)
              throws TException {
          getCurrentContext().write();
          try {
              if (getCurrentContext().isMapKey()) {
                  getCurrentWriter().writeFieldName(val.toString());
              } else {
                  helper.writeValue(getCurrentWriter(), val);
              }
          } catch (IOException ex) {
              throw new TException(ex);
          }
      }
docs: Write out the given value, either as a JSON name (meaning it's
  escaped by quotes), or a value. The TypedParser knows how to
  handle the writing.