private <T> void writeNameOrValue(TypedParser<T> helper, T val) throws TException {
        try {
            if (getCurrentContext().isMapKey()) {
                getCurrentWriter().writeFieldName(val.toString());
            } else {
                helper.writeValue(getCurrentWriter(), val);
            }
        } catch (IOException ex) {
            throw new TException(ex);
        }
    }
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.
thrift/thrift0.13/src/main/java/com/linecorp/armeria/common/thrift/text/TTextProtocol.java