def write_json(output, end='', raw=False, file=None, flush=False):
file = file or sys.stdout
if len(output) == 1:
output = output[0]
if raw:
json.dump(output, file, separators=(',', ':'), cls=JSONEncoder)
else:
json.dump(output, file, indent=4, sort_keys=True, cls=JSONEncoder)
if flush:
file.flush()
if end:
write_output(file, '', end=end, sep='', flush=flush)
评论列表
文章目录