JSON command line formatter tool for Linux [closed]

匿名 (未验证) 提交于 2019-12-03 02:44:02

问题:

Is there an editor or tool for Linux command line to format JSON data?

回答1:

 alias pp='python -mjson.tool'  pp mydata.json 

From the first link in the accepted answer: http://ruslanspivak.com/2010/10/12/pretty-print-json-from-the-command-line/



回答2:

jq is a lightweight and flexible command-line JSON processor.

http://stedolan.github.io/jq/

jq is written in portable C, and it has zero runtime dependencies. You can download a single binary, scp it to a far away machine, and expect it to work.



回答3:

On Ubuntu jsonlint is provided by apt:python-demjson

Usage:

$ sudo apt-get install python-demjson $ jsonlint -f input.json > output.json 


回答4:

Add to vimrc:

" Format JSON data map <C-F6> :%!python -m json.tool<CR> 

And you can use the shortcut CTRL+F6 to format json data


Or just under vim's command mode:

%!python -m json.tool 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!