Skip to content

Commit c1fce71

Browse files
author
Jonathan Hilliard
committed
Added comment.
1 parent 97e18f3 commit c1fce71

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

jsonpatch.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,13 @@ def _compare_values(self, path, key, src, dst):
825825
isinstance(dst, MutableSequence):
826826
self._compare_lists(_path_join(path, key), src, dst)
827827

828+
# To ensure we catch changes to JSON, we can't rely on a simple
829+
# src == dst, or it would not recognize the difference between
830+
# 1 and True, among other things. Using json.dumps is the most
831+
# fool-proof way to ensure we catch type changes that matter to JSON
832+
# and ignore those that don't. The performance of this could be
833+
# improved by doing more direct type checks, but we'd need to be
834+
# careful to accept type changes that don't matter when JSONified.
828835
elif json.dumps(src) == json.dumps(dst):
829836
return
830837

0 commit comments

Comments
 (0)