@@ -21,17 +21,19 @@ def main():
2121 'to validate and pretty-print JSON objects.' )
2222 parser = argparse .ArgumentParser (prog = prog , description = description )
2323 parser .add_argument ('infile' , nargs = '?' , type = argparse .FileType (),
24- help = 'a JSON file to be validated or pretty-printed' )
24+ help = 'a JSON file to be validated or pretty-printed' ,
25+ default = sys .stdin )
2526 parser .add_argument ('outfile' , nargs = '?' , type = argparse .FileType ('w' ),
26- help = 'write the output of infile to outfile' )
27+ help = 'write the output of infile to outfile' ,
28+ default = sys .stdout )
2729 parser .add_argument ('--sort-keys' , action = 'store_true' , default = False ,
2830 help = 'sort the output of dictionaries alphabetically by key' )
2931 parser .add_argument ('--json-lines' , action = 'store_true' , default = False ,
3032 help = 'parse input using the jsonlines format' )
3133 options = parser .parse_args ()
3234
33- infile = options .infile or sys . stdin
34- outfile = options .outfile or sys . stdout
35+ infile = options .infile
36+ outfile = options .outfile
3537 sort_keys = options .sort_keys
3638 json_lines = options .json_lines
3739 with infile , outfile :
0 commit comments