-
Notifications
You must be signed in to change notification settings - Fork 0
Home
brianburwell11 edited this page Jun 21, 2022
·
7 revisions
Generate prettier and more compact JSON dumps
prettierjson can be installed directly from the GitHub repository using one of these commands:
pip install git+ssh://git@github.com/brianburwell11/prettierjson.git@masterpoetry add git+ssh://git@github.com/brianburwell11/prettierjson.git#master- prettierjson.prettierjson
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