Pretty print json output when writing to a file
It's the opposite of fun to read a single line of json output when generating the graph results, so if using the -o option to write to a file, indent the output for readability. Change-Id: I091ee2ade51def2d59cdeadb792e56746f8882a2
This commit is contained in:
parent
4b42cef7f5
commit
4cdc4be2e6
|
@ -231,7 +231,9 @@ def main():
|
|||
out = sys.stdout
|
||||
|
||||
try:
|
||||
out.write(json.dumps(jsondata))
|
||||
# indent the json output if we're writing to a file
|
||||
indent = 4 if args.output else None
|
||||
out.write(json.dumps(jsondata, indent=indent))
|
||||
finally:
|
||||
out.close()
|
||||
|
||||
|
|
Loading…
Reference in New Issue