python-json-patch icon indicating copy to clipboard operation
python-json-patch copied to clipboard

bug: jsonpatch does not play nice with "/" in dict keys

Open johnarnold opened this issue 6 years ago • 1 comments

Version: 1.23 Issue: Jsonpatch doesn't handle "/" characters correctly. E.g. when trying to create a patch/diff from an existing dictionary, if there is "/" in a key, it adds/substitutes "~1"

Minimum repro:

import jsonpatch
test_dict = {'/fields/test': '123456'}
patch = jsonpatch.make_patch({}, test_dict)
patch.patch

Expected:

[{'op': 'add', 'path': '/fields/test', 'value': '123456'}]

Actual:

[{'op': 'add', 'path': '/~1fields~1test', 'value': '123456'}]

johnarnold avatar Mar 21 '19 01:03 johnarnold

Actually, is this expected behavior? (reading the RFC...)

johnarnold avatar Mar 21 '19 01:03 johnarnold