You can use embed language .
Example:
String myJsonString = "";
- Place the cursor between "and".
- Alt + Enter -> Insert language or link -> select json from the drop-down list,
- Now you have entered json on this line. Again Alt + Enter -> Edit Json Snippet.
- Now you can give your json inside the popup tool like regular json, Intellij will convert it as String with escape characters for you. :))

See more details.
source share