Skip to main content

A json pretty printer for python

Project description

pprintjson

PyPi release Downloads

A json pretty printer for Python 🐍.

Installation

$ pip install pprintjson

Usage

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 <str> to 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 -c '{ "a": 1, "b": "string", "c": true }'

Pretty print JSON from a string with an indent of 1.

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

Pretty print JSON from a string and save output to a file output.json.

$ pprintjson -c '{ "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)

stdout

License

MIT © Travis Clarke

Project details


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.2.1.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pprintjson-1.2.1-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file pprintjson-1.2.1.tar.gz.

File metadata

  • Download URL: pprintjson-1.2.1.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for pprintjson-1.2.1.tar.gz
Algorithm Hash digest
SHA256 75bb0bff7542a272cfeb963319ed02f450c04e2fe4e47b518399431f6c901f3e
MD5 d0d1b7b1600b7f576f21acaf6737013e
BLAKE2b-256 a7b749b29fbcd37a5b87e5b871fd5c601f7b0e4f0754eb6331ce6f1697ad070e

See more details on using hashes here.

File details

Details for the file pprintjson-1.2.1-py3-none-any.whl.

File metadata

  • Download URL: pprintjson-1.2.1-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for pprintjson-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d01fd53909a51911a6b028ef769db1501d77021efe1bfb1a20ba1457af758588
MD5 fb0add5a5ecd1006b38f5e621b825c44
BLAKE2b-256 8fdc56a9305021c064ab44d25c115c9154e098d83cd699fea945ef9304cdd7b5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page