Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Support /- and nested properties#19

Merged
marcbachmann merged 1 commit into
janl:masterjanl/node-jsonpointer:masterfrom
marcbachmann:set-improvementCopy head branch name to clipboard
Sep 29, 2015
Merged

Support /- and nested properties#19
marcbachmann merged 1 commit into
janl:masterjanl/node-jsonpointer:masterfrom
marcbachmann:set-improvementCopy head branch name to clipboard

Conversation

@marcbachmann

Copy link
Copy Markdown
Collaborator

Adds set /- support, adds nested property setter:

// set nested properties
assert.equal(jsonpointer.set(obj, "/f/g/h/i", 6), undefined);
assert.equal(jsonpointer.get(obj, "/f/g/h/i"), 6);

// set an array
assert.equal(jsonpointer.set(obj, "/f/g/h/foo/-", 'test'), undefined);
arr = jsonpointer.get(obj, "/f/g/h/foo")
assert(Array.isArray(arr), 'set /- creates an array.');
assert.equal(arr[0], 'test');

Requested in #14

@marcbachmann

Copy link
Copy Markdown
Collaborator Author

This is an improvement over the current implementation where we've just returned null.
At least setting values works now.
There are no downsides as I can see. However, I will do a major release. I don't want to break other libraries.

marcbachmann added a commit that referenced this pull request Sep 29, 2015
@marcbachmann marcbachmann merged commit 7e9d053 into janl:master Sep 29, 2015
@marcbachmann marcbachmann deleted the set-improvement branch September 29, 2015 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.