Skip to content
JSON Pointer implementation for Node.js
JavaScript
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
.travis.yml chore: tmp disable node 4 Oct 18, 2017
LICENSE.md add MIT license file Sep 5, 2015
README.md Add CLI, closes #29 Oct 18, 2017
benchmark.js Add simple benchmark May 11, 2016
jsonpointer.d.ts typings added Aug 25, 2017
jsonpointer.js Support 'null' as a valid value to set as a property, use 'undefined'… May 19, 2016
package-lock.json chore(package): update lockfile Feb 19, 2018
package.json chore(package): update standard to version 11.0.0 Feb 19, 2018
test.js Support 'null' as a valid value to set as a property, use 'undefined'… May 19, 2016

README.md

JSON Pointer for nodejs

Greenkeeper badge

This is an implementation of JSON Pointer.

CLI

Looking to filter JSON from the command line? Check out jsonpointer-cli.

Usage

var jsonpointer = require('jsonpointer');
var obj = { foo: 1, bar: { baz: 2}, qux: [3, 4, 5]};

jsonpointer.get(obj, '/foo');     // returns 1
jsonpointer.get(obj, '/bar/baz'); // returns 2
jsonpointer.get(obj, '/qux/0');   // returns 3
jsonpointer.get(obj, '/qux/1');   // returns 4
jsonpointer.get(obj, '/qux/2');   // returns 5
jsonpointer.get(obj, '/quo');     // returns undefined

jsonpointer.set(obj, '/foo', 6);  // sets obj.foo = 6;
jsonpointer.set(obj, '/qux/-', 6) // sets obj.qux = [3, 4, 5, 6]

var pointer = jsonpointer.compile('/foo')
pointer.get(obj)    // returns 1
pointer.set(obj, 1) // sets obj.foo = 1

Testing

$ node test.js
All tests pass.
$

Build Status

Author

(c) 2011-2015 Jan Lehnardt jan@apache.org & Marc Bachmann https://github.com/marcbachmann

License

MIT License.

You can’t perform that action at this time.