Skip to content

Commit cc37e25

Browse files
authored
Merge pull request #127 from Genzer/master
Add support for preserving Unicode characters in jsonpatch CLI
2 parents dbea3db + 974d54f commit cc37e25

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

bin/jsonpatch

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ parser.add_argument('-i', '--in-place', action='store_true',
2424
help='Modify ORIGINAL in-place instead of to stdout')
2525
parser.add_argument('-v', '--version', action='version',
2626
version='%(prog)s ' + jsonpatch.__version__)
27-
27+
parser.add_argument('-u', '--preserve-unicode', action='store_true',
28+
help='Output Unicode character as-is without using Code Point')
2829

2930
def main():
3031
try:
@@ -72,8 +73,8 @@ def patch_files():
7273

7374
# By this point we have some sort of file object we can write the
7475
# modified JSON to.
75-
76-
json.dump(result, fp, indent=args.indent)
76+
77+
json.dump(result, fp, indent=args.indent, ensure_ascii=not(args.preserve_unicode))
7778
fp.write('\n')
7879

7980
if args.in_place:

doc/commandline.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,12 @@ The program ``jsonpatch`` is used to apply JSON patches on JSON files. ::
7474
PATCH Patch file
7575
7676
optional arguments:
77-
-h, --help show this help message and exit
78-
--indent INDENT Indent output by n spaces
79-
-v, --version show program's version number and exit
80-
77+
-h, --help show this help message and exit
78+
--indent INDENT Indent output by n spaces
79+
-b, --backup Back up ORIGINAL if modifying in-place
80+
-i, --in-place Modify ORIGINAL in-place instead of to stdout
81+
-v, --version show program's version number and exit
82+
-u, --preserve-unicode Output Unicode character as-is without using Code Point
8183
8284
Example
8385
^^^^^^^

0 commit comments

Comments
 (0)