Skip to main content

pprintjson

PyPi release PyPi versions Downloads Documentation Status

A json pretty printer for Python 🐍.

Check out the pprintjson docs

Installation

Install with the standard json JSON encoder

$ pip install pprintjson

Install with the premier simplejson JSON encoder

$ pip install pprintjson[simplejson]

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 <cmd> 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 stdin using the pprintjson CLI.

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

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

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.4.2.tar.gz (4.3 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.4.2-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pprintjson-1.4.2.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.7

File hashes

Hashes for pprintjson-1.4.2.tar.gz
Algorithm Hash digest
SHA256 21de6b471eb13c08e726065e18061bcfafd5f5f352e02fb6e7410d87b2f8b22d
MD5 c6e6b3c48a0283991fee03f698dd7fbd
BLAKE2b-256 816694589d66848e879589e3082a3aeb38f64ea56d59668f9302a5e50d69e192

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pprintjson-1.4.2-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.7

File hashes

Hashes for pprintjson-1.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5ae1300302db2d377c2de239c0a0ea8835e77232ad293bcbcfb0c90f872d7103
MD5 eee8479620ddc00c7ca6a398ba318813
BLAKE2b-256 b82ba09d9b693b8880bbaeac6892eb159bdc97ccae660ccd62249eb356aff852

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.4.2 This release

2 files

1.4.1

2 files

1.4.0

2 files

1.3.0

2 files

1.2.1

2 files

1.2.0

2 files

1.1.4

2 files

1.1.3

2 files

1.1.2

2 files

1.1.1

2 files

1.1.0

2 files

1.0.1

2 files

1.0.0

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

Supported by

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