A json pretty printer for python
Project description
pprintjson
A json pretty printer for Python 🐍.
Installation
$ pip install pprintjson
Usage
usage: pprintjson.py [-h] [-i num] [-o file] [-s cmd] [-v] [file]
A pretty-printing function for json.
positional arguments:
file file to json 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)
-s cmd, --string cmd string to json pretty-print
-v, --version show program's version number and exit
Script
Pretty print JSON from a file using the pprintjson
CLI.
$ pprintjson "./path/to/file.json"
Pretty print JSON from a string using the pprintjson
CLI.
$ pprintjson -s '{ "a": 1, "b": "string", "c": true }'
Pretty print JSON from a string with an indent of 1.
$ pprintjson -s '{ "a": 1, "b": "string", "c": true }' -i 1
Pretty print JSON from a string and save output to a file output.json.
$ pprintjson -s '{ "a": 1, "b": "string", "c": true }' -o ./output.json
Module
Pretty print JSON from a dict using the pprintjson
module.
# 1. import the "pprintjson" function.
from pprintjson import pprintjson as ppjson
# 2. pretty print JSON.
obj = { "a": 1, "b": "string", "c": True }
ppjson(obj)
License
MIT © Travis Clarke
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pprintjson-1.1.2.tar.gz
(3.5 kB
view hashes)
Built Distribution
Close
Hashes for pprintjson-1.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dde67b4047f676293c212f4292b3687b7f79bbe3087570cc386d06968d626e75 |
|
MD5 | 36fd5a9843bbfa2dbf146f8fef083062 |
|
BLAKE2b-256 | ae47674e0ab65cded3dccb8c1300ea14480536d5b1112f7f473a4b5e450b87f8 |