in spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/json-shade/java/org/springframework/boot/configurationprocessor/json/JSONStringer.java [313:362]
private void string(String value) {
this.out.append("\"");
for (int i = 0, length = value.length(); i < length; i++) {
char c = value.charAt(i);
/*
* From RFC 4627, "All Unicode characters may be placed within the quotation
* marks except for the characters that must be escaped: quotation mark,
* reverse solidus, and the control characters (U+0000 through U+001F)."
*/
switch (c) {
case '"':
case '\\':
case '/':
this.out.append('\\').append(c);
break;
case '\t':
this.out.append("\\t");
break;
case '\b':
this.out.append("\\b");
break;
case '\n':
this.out.append("\\n");
break;
case '\r':
this.out.append("\\r");
break;
case '\f':
this.out.append("\\f");
break;
default:
if (c <= 0x1F) {
this.out.append(String.format("\\u%04x", (int) c));
}
else {
this.out.append(c);
}
break;
}
}
this.out.append("\"");
}