文本模板(String Templates/Preview):
String[] a = { "X", "Y", "Z" }; // 也支持\{user.name()}等;嵌套用法:
String r = STR."\{a[0]}, \{STR."\{a[1]}, \{a[2]}"}";
var JSON = StringTemplate.Processor.of(
(StringTemplate st) -> new JSONObject(st.interpolate())
); // 多行JSON处理:
String name = "Joan Smith"; String address = "1 Maple Drive, Anytown";
JSONObject doc = JSON."""
{
"name": "\{name}",
"address": "\{address}"
};
""";