1 r
"""Using simplejson from the shell to validate and
4 $ echo '{"json":"obj"}' | python -msimplejson.tool
8 $ echo '{ 1.2:3.4}' | python -msimplejson.tool
9 Expecting property name: line 1 column 2 (char 2)
11 from django
.utils
import simplejson
15 if len(sys
.argv
) == 1:
18 elif len(sys
.argv
) == 2:
19 infile
= open(sys
.argv
[1], 'rb')
21 elif len(sys
.argv
) == 3:
22 infile
= open(sys
.argv
[1], 'rb')
23 outfile
= open(sys
.argv
[2], 'wb')
25 raise SystemExit("%s [infile [outfile]]" % (sys
.argv
[0],))
27 obj
= simplejson
.load(infile
)
30 simplejson
.dump(obj
, outfile
, sort_keys
=True, indent
=4)
34 if __name__
== '__main__':