diff options
author | Stefan Kögl <stefan@skoegl.net> | 2019-07-28 17:55:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-28 17:55:15 +0200 |
commit | 33e630e6c50fedce419ef27e88ad5c17ad7837ba (patch) | |
tree | bdbf0f96eade33297c44cd8747fa077260f18ea1 | |
parent | 2990bb3d686c09a1550083336365e99247297711 (diff) | |
parent | 53817c04a1c0e0cbaa47168c494c1d5b9bcdd94d (diff) | |
download | python-json-patch-33e630e6c50fedce419ef27e88ad5c17ad7837ba.tar.gz |
Merge pull request #99 from itkach/master
Fix move for numeric dictionary keys (issue #97)
-rw-r--r-- | jsonpatch.py | 4 | ||||
-rwxr-xr-x | tests.py | 9 |
2 files changed, 11 insertions, 2 deletions
diff --git a/jsonpatch.py b/jsonpatch.py index 4f8a02b..8ec01d3 100644 --- a/jsonpatch.py +++ b/jsonpatch.py @@ -56,7 +56,7 @@ except ImportError: # Will be parsed by setup.py to determine package metadata __author__ = 'Stefan Kögl <stefan@skoegl.net>' -__version__ = '1.22' +__version__ = '1.24' __website__ = 'https://github.com/stefankoegl/python-json-patch' __license__ = 'Modified BSD License' @@ -717,7 +717,7 @@ class DiffBuilder(object): index = self.take_index(item, _ST_REMOVE) if index is not None: op = index[2] - if type(op.key) == int: + if type(op.key) == int and type(key) == int: for v in self.iter_from(index): op.key = v._on_undo_remove(op.path, op.key) @@ -419,6 +419,15 @@ class MakePatchTestCase(unittest.TestCase): new_from_patch = jsonpatch.apply_patch(old, patch) self.assertEqual(new, new_from_patch) + def test_move_from_numeric_to_alpha_dict_key(self): + #https://github.com/stefankoegl/python-json-patch/issues/97 + src = {'13': 'x'} + dst = {'A': 'a', 'b': 'x'} + patch = jsonpatch.make_patch(src, dst) + res = jsonpatch.apply_patch(src, patch) + self.assertEqual(res, dst) + + class OptimizationTests(unittest.TestCase): def test_use_replace_instead_of_remove_add(self): |