jsonpointer / 4.0.0 last updated 2 months ago created on Jul 13th 2011

Install

npm install --save jsonpointer

Clone

git clone git@github.com:janl/node-jsonpointer.git

dependencies

No dependencies listed.

maintainers

jan
marcbachmann

versions 7 total

4.0.0 2 months ago marcbachmann
3.0.1 2 months ago marcbachmann
3.0.0 10 months ago marcbachmann
2.0.0 a year ago marcbachmann
1.1.0 4 years ago jan
1.0.1 5 years ago anonymous
1.0.0 5 years ago anonymous
135329 Downloads yesterday.

readme

JSON Pointer for nodejs

This is an implementation of JSON Pointer.

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 null

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

1
2
3
$ 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.

Resolving all dependencies.. This could take a while as our cache is not yet fully warmed up.