一个json漂亮的python打印机
pprintjson的Python项目详细描述
pprintjson
一个json漂亮的python打印机。
安装
使用标准的^{
$ pip install pprintjson
使用premier^{
$ pip install pprintjson[simplejson]
用法
usage: pprintjson.py [-h] [-i num] [-o file] [-c cmd] [-v] [file] A pretty-printing function for json. positional arguments: file json <file> to pretty-print optional arguments: -h, --help show this help message and exit -i num, --indent num indent <num> number of spaces at each level (default: 4) -o file, --output file write output to <file> instead of stdout (default: stdout) -c cmd, --command cmd json <cmd> to pretty-print -v, --version show program's version number and exit
脚本
漂亮地使用pprintjson
cli从文件中打印json。
$ pprintjson "./path/to/file.json"
漂亮地使用pprintjson
cli从stdin打印json。
$ echo'{ "a": 1, "b": "string", "c": true }'| pprintjson
漂亮地使用pprintjson
cli从string打印json。
$ pprintjson -c '{ "a": 1, "b": "string", "c": true }'
用1的indent从string漂亮地打印json。
$ pprintjson -c '{ "a": 1, "b": "string", "c": true }' -i 1
漂亮地从string打印json,并将output保存到文件output.json。
$ pprintjson -c '{ "a": 1, "b": "string", "c": true }' -o ./output.json
模块
使用pprintjson
模块从dict打印json。
# 1. import the "pprintjson" function.frompprintjsonimportpprintjsonasppjson# 2. pretty print JSON.obj={"a":1,"b":"string","c":True}ppjson(obj)
许可证
麻省理工学院Travis Clarke