Repository navigation
Add create parameter to set_pointer for auto-creating missing paths - #84
Open
stefankoegl wants to merge 1 commit into
Open
stefankoegl wants to merge 1 commit into
stefankoegl wants to merge 1 commit into
Conversation
With create=True, set_pointer and JsonPointer.set create missing intermediate members as dicts instead of raising JsonPointerException. Missing list elements can be created by referencing the end of a list with "-" or an index equal to its length. The missing structure is built detached and attached in one step, so doc is left unchanged if the pointer can't be applied. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGUKSut5p4NSKEm3mD5Ft3
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This PR adds a
createparameter to theset_pointer()function andJsonPointer.set()method that enables automatic creation of missing intermediate members when setting values in nested structures.Key Changes
create=Falseparameter toset_pointer()function andJsonPointer.set()methodcreate=True, missing intermediate dictionary members are automatically created instead of raising aJsonPointerException"-"or an index equal to the array lengthset()method to extract helper methods:_get_create_part(): Maps array indices at the end of a sequence to"-"for appending_is_missing(): Checks if a part doesn't exist but could be added_set_child(): Extracted common logic for setting values in parent containerscreateparameter usageImplementation Details
create=Falseas the defaultinplace=Trueandinplace=Falsemodeshttps://claude.ai/code/session_01WGUKSut5p4NSKEm3mD5Ft3