Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion bin/jsondiff
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ parser.add_argument('FILE1', type=argparse.FileType('r'))
parser.add_argument('FILE2', type=argparse.FileType('r'))
parser.add_argument('--indent', type=int, default=None,
help='Indent output by n spaces')
parser.add_argument('-u', '--preserve-unicode', action='store_true',
help='Output Unicode character as-is without using Code Point')
parser.add_argument('-v', '--version', action='version',
version='%(prog)s ' + jsonpatch.__version__)

Expand All @@ -32,7 +34,7 @@ def diff_files():
doc2 = json.load(args.FILE2)
patch = jsonpatch.make_patch(doc1, doc2)
if patch.patch:
print(json.dumps(patch.patch, indent=args.indent))
print(json.dumps(patch.patch, indent=args.indent, ensure_ascii=not(args.preserve_unicode)))
sys.exit(1)

if __name__ == "__main__":
Expand Down
9 changes: 5 additions & 4 deletions doc/commandline.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The JSON patch package contains the commandline utilities ``jsondiff`` and
The program ``jsondiff`` can be used to create a JSON patch by comparing two
JSON files ::

usage: jsondiff [-h] [--indent INDENT] [-v] FILE1 FILE2
usage: jsondiff [-h] [--indent INDENT] [-u] [-v] FILE1 FILE2

Diff two JSON files

Expand All @@ -19,9 +19,10 @@ JSON files ::
FILE2

optional arguments:
-h, --help show this help message and exit
--indent INDENT Indent output by n spaces
-v, --version show program's version number and exit
-h, --help show this help message and exit
--indent INDENT Indent output by n spaces
-u, --preserve-unicode Output Unicode character as-is without using Code Point
-v, --version show program's version number and exit

Example
^^^^^^^
Expand Down