A command line script for formating JSON, for example piped from cURL.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
CODE_OF_CONDUCT.md
CONTRIBUTING.md
LICENSE
README.md
cli-json.py

README.md

CLI-JSON

A CLI tool for formatting JSON.

Example:

$ curl http://api.example.net/
{"hello":"world","a":["b","c", "d"],"e":{"f":"g"},"i":[{"j":"k"},{"l":"m"}]}
$ curl http://api.example.net/ | ./cli-json.py
{
    "a": [
        "b",
        "c",
        "d"
    ],
    "i": [
        {
            "j": "k"
        },
        {
            "l": "m"
        }
    ],
    "e": {
        "f": "g"
    },
    "hello": "world"
}

JSON can be read from a file using ./cli-json.py -f file

The default indent is 4 spaces. This can be changed by adding the -i option. For example:

$ curl http://api.example.net/ | ./cli-json.py -i 3
...

The output can also be colored by adding the -c flag.

Requirements

  • Python 2.X or 3.X