Formats a text stream as JSON. Offers additional functionality over "python -mjson.tool"
> echo '[ { "foo" : "bar", "hello" : 1 }]' | python formatjson.py --indent 2
[
{
"foo": "bar",
"hello": 1
}
]
> curl https://api.twitter.com/1/statuses/public_timeline.json | python formatjson.py
[
{
"favorited": false,
"in_reply_to_user_id": null,
"contributors": null,
"truncated": false,
"text": "IT GETS REAL NASTY !!!",
"created_at": "Tue Nov 22 19:51:11 +0000 2011",
"retweeted": false,
...
}
]
> echo '{ "c" : 3, "b" : 2, "a" : 1 }' | python formatjson.py --sort-keys
{
"a": 1,
"b": 2,
"c": 3
}
-h, --help show this help message and exit
-i level, --indent level
level of indentation (default 4)
-c separator, --item-separator separator
dictionary seperator (default ',')
-d separator, --dict-separator separator
dictionary seperator (default ':')
-s, --sort-keys sorts output by key
-w, --strip-whitespace
remove whitespace from output (compact JSON)