@@ -21,17 +21,19 @@ def main():
21
21
'to validate and pretty-print JSON objects.' )
22
22
parser = argparse .ArgumentParser (prog = prog , description = description )
23
23
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 )
25
26
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 )
27
29
parser .add_argument ('--sort-keys' , action = 'store_true' , default = False ,
28
30
help = 'sort the output of dictionaries alphabetically by key' )
29
31
parser .add_argument ('--json-lines' , action = 'store_true' , default = False ,
30
32
help = 'parse input using the jsonlines format' )
31
33
options = parser .parse_args ()
32
34
33
- infile = options .infile or sys . stdin
34
- outfile = options .outfile or sys . stdout
35
+ infile = options .infile
36
+ outfile = options .outfile
35
37
sort_keys = options .sort_keys
36
38
json_lines = options .json_lines
37
39
with infile , outfile :
0 commit comments