Issue
This is my string JSON using normle string in java:
String requestJson = "{"
+ "\"Mytitle\": \""+title+"\","
+ " \"Mydescription\": \""+ description + "\""
+ "}";
Where title and description are variables. can i achieve the same result using Java Multiline String(""" """)?
Solution
You can use the formatted
method.
String requestJson = """
{
"Mytitle": "%s",
"Mydescription": "%s"
}"""
.formatted(title, description);
Answered By - Federico klez Culloca
Answer Checked By - Cary Denson (JavaFixing Admin)