Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 331
User4506837 Avatar asked Oct 25 '16 15:10

User4506837


People also ask

Can we format JSON in IntelliJ?

IntelliJ IDEA helps you work with JSON files — it checks their syntax and formatting. In popular types of configuration files, IntelliJ IDEA provides code completion, thanks to the JSON Schema, which is a special format for describing the structure and contents of such files.

How do I beautify JSON in Pycharm?

In the Settings/Preferences dialog ( Ctrl+Alt+S ), go to Editor | Color Scheme | JSON.

How use JSON Diff in IntelliJ?

Getting Started. From context menu (right-click mouse) when one or two JSON files (. json extension) selected. Option "Compare JSON File With..." or "Compare JSON Files".


1 Answers

You can use inject language feature.

Ex:

String myJsonString = "";
  • Place cursor between " and ".
  • Alt + Enter -> Inject language or reference -> select json from the dropdown appears,
  • 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 official documentation for more info.

like image 98
Supun Wijerathne Avatar answered Sep 19 '22 16:09

Supun Wijerathne