Skip to content

Commit fb5d984

Browse files
committed
Add support for disabling ensure_ascii in json.tool
1 parent a47f396 commit fb5d984

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Lib/json/tool.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ def main():
3737
help='a JSON file to be validated or pretty-printed')
3838
parser.add_argument('outfile', nargs='?', type=argparse.FileType('w'),
3939
help='write the output of infile to outfile')
40+
parser.add_argument('--no_escape', action='store_true', default=False,
41+
help='Do not set ensure_ascii to escape non-ASCII characters')
4042
parser.add_argument('--indent', default='4', type=parse_indent,
4143
help='Indent level or str for pretty-printing. '
4244
'Use None for the most compact representation. '
@@ -62,6 +64,7 @@ def main():
6264
with outfile:
6365
json.dump(obj, outfile,
6466
indent=options.indent,
67+
ensure_ascii=not options.no_escape,
6568
sort_keys=options.sort_keys,
6669
)
6770
outfile.write('\n')

0 commit comments

Comments
 (0)