有没有Linux命令行的编辑器或工具来格式化JSON数据?
我使用node.js:skovalyov.blogspot.com/2012/09/&hellip实现了我自己的in coffeescript运行。
jq很棒。您有jquery-like的json接口(主页上说它是针对json的sed)stedolan.github.io
stackoverflow.com/questions/352098/how-can-i-pretty-print-js‌&8203;打开
alias pp='python -mjson.tool'
pp mydata.json
from the accepted in the first链接答案:http://///ruslanspivak.com 2010年10 - 12 /漂亮的JSON -打印-从- the -命令行/P></
链接是死的:(
过时的答案。使用带。
lightweight JQ是JSON和灵活的命令行处理器。P></
http:/ / / / stedolan.github.io JQP></
JQ is like sed使用JSON数据–for You can it to filter和map和螺旋结构和变换日期with the same that SED轻松,让你的朋友awk grep,播放与文本。P></
便携式JQ is written in C运行时,和它有零限制。你可以下载它在二进制单SCP,呼机和远,它的工作。P></
这个解决方案似乎是对我最好的:易于安装,和一个输出命令从输入属性这可能是有时非常实用的文档时,它readability创作更好的支持。典型用途:$ jq . data.json(注意点后jq)。
JQ是一流的。注意,这不会工作。jq . data.json > data.json。这将覆盖它。一个出口温度和覆盖现有的文件。
Ubuntu提供apt:python-demjson在线jsonlint is byP></
用途:P></
$ sudo apt-get install python-demjson
$ jsonlint -f input.json > output.json
JSON的伟大当你看不到符合规格。其他工具(jqPython模块,json)需要完全conformant JSON为他们工作。
它似乎是在当前安装的软件包命令与"Python"demjson"包装是jsonlint Py"而不是"jsonlint"。
vimrc:add toP></
" Format JSON data
map :%!python -m json.tool
你可以使用快捷键Ctrl + F6 to the JSON数据格式P></
或只是在vim' S模式:命令行P></
%!python -m json.tool
如果你使用Vim中你可以与=:au FileType json set equalprg=python\ -m\ json.tool和格式。