2 # -*- coding: utf-8 -*-
4 """jsonfmt.py - JSON formatter
6 File ID: 423dd854-4a64-11e4-97b1-c80aa9e67bbd
7 License: GNU General Public License version 2 or later.
8 Author: Øyvind A. Holm <sunny@sunbase.org>
13 def format_json(text
, indent
=4):
14 """Return formatted JSON"""
30 progname
= os
.path
.basename(__file__
)
32 parser
= argparse
.ArgumentParser(
33 description
="JSON formatter",
39 help="Use X spaces as indent",
43 args
= parser
.parse_args()
48 "".join(sys
.stdin
.readlines()),
53 sys
.stderr
.write("%s: Invalid JSON\n" % progname
)
56 if __name__
== "__main__":