Skip to content
brianburwell11 edited this page Jun 21, 2022 · 7 revisions

Module prettierjson

prettierjson

made-with-python Code style: black Github release Documentation

Generate prettier and more compact JSON dumps

Installation

prettierjson can be installed directly from the GitHub repository using one of these commands:

pip install git+ssh://git@github.com/brianburwell11/prettierjson.git@master
poetry add git+ssh://git@github.com/brianburwell11/prettierjson.git#master

Usage

Sub-modules

  • prettierjson.prettierjson

Functions

dumps(obj, indent=2, max_line_length=80) : Renders JSON content with indentation and line splits/concatenations to fit max_line_length.

Only dicts, lists and basic types are supported

Parameters
----------
obj : dict, list, tuple, str
    A python object to be converted to JSON
indent : int, optional
    How many spaces to use as an indent before nested keys. Default is 2
max_line_length : int, optional
    How many characters to limit a single line to before wrapping to the next line. Default is 80 characters

Returns
-------
str
    A representation of the JSON to be piped to a .json file

Clone this wiki locally