Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: null values throwing exception when traversing over while getting #50

merged 3 commits into from Jul 13, 2022


Copy link

@reckter reckter commented Jul 15, 2020

Previously getting any value, where an object in the path was null, would throw an exception, while it being undefined would not.


const obj = {
   foo: null,
   baz: undefined

jsonpointer.get(obj, "/foo/baz") /// <--- This would throw
jsonpointer.get(obj, "/baz/foo") /// <---- This would not

The fix is simply also checking equality with null and then returning null (comparable to the undefined case, where it already returned null)

Copy link

@marcbachmann marcbachmann left a comment

Thanks for the fixes. I've introduced some better test assertions in #59 and rebased against it to get it in.
I also did a small fix to return undefined for .get('/nullValue/something')
IMO we can merge this once the other PR is merged.

Copy link
Contributor Author

reckter commented Jan 24, 2022

Feel free to merge at will, I don't actually work with this library anymore, because the project is over where I used it, so you have full authority to merge and change at will :)

@marcbachmann marcbachmann merged commit 4a253c0 into janl:main Jul 13, 2022
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

None yet

2 participants