Skip to content

Repository files navigation

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

varjsonpointer=require('jsonpointer');varobj={foo: 1,bar: {baz: 2},qux: [3,4,5]};jsonpointer.get(obj,'/foo');// returns 1jsonpointer.get(obj,'/bar/baz');// returns 2jsonpointer.get(obj,'/qux/0');// returns 3jsonpointer.get(obj,'/qux/1');// returns 4jsonpointer.get(obj,'/qux/2');// returns 5jsonpointer.get(obj,'/quo');// returns undefinedjsonpointer.set(obj,'/foo',6);// sets obj.foo = 6;jsonpointer.set(obj,'/qux/-',6)// sets obj.qux = [3, 4, 5, 6]varpointer=jsonpointer.compile('/foo')pointer.get(obj)// returns 1pointer.set(obj,1)// sets obj.foo = 1

Testing

$ npm test
All tests pass.
$

Node.js CI

Author

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

Thanks to all contributors.

License

MIT License.

About

JSON Pointer (RFC6901) implementation for Node.js

Topics

Resources

Stars

197 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages