private String optionallyQuoteKey(Object key, String indent) {
            String formatted = AbstractCodeWriter.formatLiteral(key);
            if (UNQUOTED_KEY_STRING.matcher(formatted).matches()) {
                return formatted;
            }
            return StringUtils.escapeJavaString(formatted, indent);
        }
Formatter that quotes (and escapes) a string unless it's a valid object key string.
smithy-model/src/main/java/software/amazon/smithy/model/shapes/SmithyIdlModelSerializer.java