Skip to content

Conversation

@marcbachmann
Copy link
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
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