问题提出
有时候第三方提供的json文件,是不带缩进信息的,看起来比较头疼,如下图:
我们可以通过在vs code中安装一个json美化扩展进行格式化处理。
通过vs code插件管理器,安装json美化插件
JSON插件使用说明
Beautify JSON.
Features
- Open new untitled / On current json file
- Whole file / Selected Text
Usage
# Notice: beautified result will replace whole file context.
Option 1
- Press
Ctrl
+Shift
+J
, quick beautify with default config.Indent: 2
PrimitiveType: keep
Option 2
- Press
Ctrl
+Shift
+P
, chooseBeautify JSON
. - On picker, select
Indent
you want. - On picker, select
Primitive Type
solution.
Configuration
- Click
Settings Icon
- Search
json.indent
json.primitiveType
使用案例
用vs code打开你要格式化的json文件,然后按下“CTRL+SHIPT+J”
格式化的效果如下: