Skip to main content

A Python-based JSON file formatter

Project description

prettyson

CI codecov

A Python-based JSON file formatter, inspired by Black.

installation

You can install prettyson via pip:

$ python3 -m pip install prettyson

how to use

Using prettyson is very simple; you just pass it the JSON files you want to format.

$ prettyson my_json_file.json my_json_files/*.json

By default, prettyson will reformat your files in-place if they are incorrectly formatted. If you just want to check your files, but not reformat them (as you would in a pre-commit or CI context for example), you can use the dry run option:

$ prettyson --dry-run my_json_file.json

If you also want it to sort the JSON keys, use the sort option:

$ prettyson --sort my_json_file.json

By default, the indentation that is used is four spaces; you could specify a different amount of spaces via the indent option, or use tabs instead via the use tabs option:

$ prettyson --indent 2 my_json_file.json # 2-space indentation
$ prettyson --use-tabs my_json_file.json # tab indentation

You can get an exhaustive list of options by running:

$ prettyson --help

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

prettyson-0.0.2.tar.gz (16.6 kB view hashes)

Uploaded Source

Built Distribution

prettyson-0.0.2-py3-none-any.whl (18.3 kB view hashes)

Uploaded Python 3

Supported by

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