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>
12 def format_json(text
, indent
=4):
13 """Return formatted JSON"""
28 progname
= os
.path
.basename(__file__
)
30 parser
= argparse
.ArgumentParser(
31 description
='JSON formatter',
36 help='Use X spaces as indent',
40 args
= parser
.parse_args()
43 print(format_json(''.join(sys
.stdin
.readlines()),
47 sys
.stderr
.write("%s: Invalid JSON\n" % progname
)
49 if __name__
== "__main__":