JSON格式化工具

时间:2023-01-14 18:38:52

I use PHPstorm IDE and would like to find a plugin to format JSON so that it is easier for me to read.

我使用PHPstorm IDE,并希望找到一个插件来格式化JSON,这样便于我阅读。

Currently I have this in a file displayed in the IDE:

目前我有一个文件显示在IDE中:

{"property":"value1","property2":"value2","array1":[{"attr1":"value1"},{"attr2":"value2"}]}

I would like a plugin I can run so that I can look at this instead:

我想要一个可以运行的插件,这样我就可以看到它:

{
   "property": "value1",
   "property2": "value2",
   "array1": [
      {
         "attr1": "value1"
      },{
         "attr2": "value2"
      }
   ]
}

I found the following plugin, but it does not seem to work with PHPStorm : http://plugins.jetbrains.com/plugin/3964?pr=

我找到了下面的插件,但是它似乎不能使用PHPStorm: http://plugins.jetbrains.com/plugin/3964?pr=

2 个解决方案

#1


30  

It is possibly because I'm new to PHPStorm, but the option in the menu Code -> Reformat Code (CTRL + ALT + L) does the job fine in a .json file, and goes an ok job in a .js file.

这可能是因为我刚接触PHPStorm,但是菜单代码中的选项> Reformat代码(CTRL + ALT + L)在.json文件中做得很好,在.js文件中做得很好。

#2


0  

In phpStorm 2017

2017年phpStorm

File > Settings > Editor > Code Style > JSON

文件>设置>编辑器>代码风格> JSON

Then set tab size, indent, and continuation indent.

然后设置制表符大小、缩进和延续缩进。

Or "Set from..." if you have defined indentation for other code style and want to copy it.

如果您已经为其他代码样式定义了缩进,并想要复制它,那么“Set from…”

#1


30  

It is possibly because I'm new to PHPStorm, but the option in the menu Code -> Reformat Code (CTRL + ALT + L) does the job fine in a .json file, and goes an ok job in a .js file.

这可能是因为我刚接触PHPStorm,但是菜单代码中的选项> Reformat代码(CTRL + ALT + L)在.json文件中做得很好,在.js文件中做得很好。

#2


0  

In phpStorm 2017

2017年phpStorm

File > Settings > Editor > Code Style > JSON

文件>设置>编辑器>代码风格> JSON

Then set tab size, indent, and continuation indent.

然后设置制表符大小、缩进和延续缩进。

Or "Set from..." if you have defined indentation for other code style and want to copy it.

如果您已经为其他代码样式定义了缩进,并想要复制它,那么“Set from…”