一个json漂亮的python打印机

pprintjson的Python项目详细描述


pprintjson

PyPi releaseDownloadsDocumentation Status

一个json漂亮的python打印机。

Check out the pprintjson docs

安装

使用标准的^{}json编码器安装

$ pip install pprintjson

使用premier^{}json编码器安装

$ 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

脚本

漂亮地使用pprintjsoncli从文件中打印json。

$ pprintjson "./path/to/file.json"

漂亮地使用pprintjsoncli从stdin打印json。

$ echo'{ "a": 1, "b": "string", "c": true }'| pprintjson

漂亮地使用pprintjsoncli从string打印json。

$ pprintjson -c '{ "a": 1, "b": "string", "c": true }'

1的indentstring漂亮地打印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)

stdout

许可证

麻省理工学院Travis Clarke

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
有没有一种方法可以将不同的java web应用程序组合到一个web应用程序(war)中而不相互影响?   java一次屏蔽两位   java如何在多个类上初始化元素?   java在后台服务中处理通知或使用GCM(或其他推送通知服务)   java从const方法调用JNI函数   javascript如何使用函数/方法返回?   Java优化:声明类变量与使用临时变量   java字符算术基数8 vs基数10   Java流收集要存储的对象列表   swing我正在用Java中的keyListener制作一个精灵移动器   在Gradle构建脚本中使用Scala(或java)方法   java Android Mediaplayer下一步按钮不起作用   Java Sound API在播放音频文件后将其锁定   java将变量从外部类传递到内部类的最佳方法   使用play framework的博客web应用程序出现java逻辑错误   java我们可以在Spring批处理中处理大型zip文件吗?   java如何检查JTable的选定行的特定列中的值是否已经在JList中?