You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Addresses the issue where / characters in dictionary keys cause unexpected JSON Patch paths (e.g. /~1fields~1test instead of /fields/test). This is correct behavior per RFC 6901, but users who intend their slash-containing keys as path separators can now use the new expand_slash_keys() utility to convert their flat dict to a nested structure before patching.
Changes Made
New utility function expand_slash_keys() in jsonpatch.py: converts a flat dictionary with slash-separated path-like keys into a nested dictionary, so that make_patch generates human-readable JSON Pointer paths. Raises ValueError if two keys produce conflicting paths (e.g. 'a' and 'a/b' both present).
Tests: Added 6 unit tests for expand_slash_keys covering simple leading-slash keys, mixed slashed/plain keys, deep nesting, no-slash passthrough, make_patch integration, and the conflict error case.
CI fix: Corrected --source=jsonpointer → --source=jsonpatch in test.yaml, removed the unsupported Python 2.7 entry from the test matrix, and added Python 3.12.
Testing
✅ All 124 tests pass (coverage run --source=jsonpatch tests.py)
✅ No CodeQL security alerts
📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.
Added expand_slash_keys() utility in jsonpatch.py — converts flat dicts with slash-separated path-like keys into nested dicts, so make_patch produces readable JSON Pointer paths (e.g. {'/fields/test': '123456'} → {'fields': {'test': '123456'}}). Raises ValueError on conflicting key paths.
Added 6 tests for expand_slash_keys covering: simple leading-slash key, mixed slashed/plain keys, deep nesting, no slashes, make_patch integration, and the conflict error case.
Fixed test.yaml CI: corrected --source=jsonpointer → --source=jsonpatch (this repo is jsonpatch, not jsonpointer), removed Python 2.7 from the matrix (not supported by actions/setup-python@v4), and added Python 3.12.
CopilotAI
changed the title
[WIP] bug: jsonpatch does not play nice with "/" in dict keys
bug: jsonpatch does not play nice with "/" in dict keys
Mar 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses the issue where
/characters in dictionary keys cause unexpected JSON Patch paths (e.g./~1fields~1testinstead of/fields/test). This is correct behavior per RFC 6901, but users who intend their slash-containing keys as path separators can now use the newexpand_slash_keys()utility to convert their flat dict to a nested structure before patching.Changes Made
expand_slash_keys()injsonpatch.py: converts a flat dictionary with slash-separated path-like keys into a nested dictionary, so thatmake_patchgenerates human-readable JSON Pointer paths. RaisesValueErrorif two keys produce conflicting paths (e.g.'a'and'a/b'both present).expand_slash_keyscovering simple leading-slash keys, mixed slashed/plain keys, deep nesting, no-slash passthrough,make_patchintegration, and the conflict error case.--source=jsonpointer→--source=jsonpatchintest.yaml, removed the unsupported Python 2.7 entry from the test matrix, and added Python 3.12.Testing
coverage run --source=jsonpatch tests.py)📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.