JSON Pointer for Node.js
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');
jsonpointer.get(obj, '/bar/baz');
jsonpointer.get(obj, '/qux/0');
jsonpointer.get(obj, '/qux/1');
jsonpointer.get(obj, '/qux/2');
jsonpointer.get(obj, '/quo');
jsonpointer.set(obj, '/foo', 6);
jsonpointer.set(obj, '/qux/-', 6)
var pointer = jsonpointer.compile('/foo')
pointer.get(obj)
pointer.set(obj, 1)
Testing
$ npm test
All tests pass.
$
Author
(c) 2011-2021 Jan Lehnardt jan@apache.org & Marc Bachmann https://github.com/marcbachmann
Thanks to all contributors.
License
MIT License.