Skip to content

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

Open
@johnarnold

Description

@johnarnold

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'}]

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions