User4506837 User4506837 - 6 months ago 94
JSON Question

Format Json Strings intellij?

I am developing Java using intellij idea. And I want to assign a json like format to a Java String. But I am tired with escape characters that I have to deal with.

Is there any easy tool to format without escape characters?


You can use inject language feature.


String myJsonString = "";
  • Place cursor between " and ".
  • Alt + Enter -> Inject language or reference -> select json,
  • Now you have injected json to that String. Again Alt + Enter -> Edit Json Fragment.
  • Now you can give your json inside pop-up tool as a normal json, Intellij will convert it as a String with escape characters for you. :))

enter image description here

Refer this for more.