Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/janl/node-jsonpointer
JSON Pointer (RFC6901) implementation for Node.js
https://github.com/janl/node-jsonpointer
json jsonpointer rfc6901
Last synced: 6 days ago
JSON representation
JSON Pointer (RFC6901) implementation for Node.js
- Host: GitHub
- URL: https://github.com/janl/node-jsonpointer
- Owner: janl
- License: mit
- Created: 2011-07-13T22:20:18.000Z (over 13 years ago)
- Default Branch: main
- Last Pushed: 2022-12-08T06:36:05.000Z (about 2 years ago)
- Last Synced: 2024-11-22T03:35:06.095Z (about 1 month ago)
- Topics: json, jsonpointer, rfc6901
- Language: JavaScript
- Homepage: https://tools.ietf.org/html/rfc6901
- Size: 564 KB
- Stars: 196
- Watchers: 6
- Forks: 28
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# JSON Pointer for Node.js
This is an implementation of [JSON Pointer](https://tools.ietf.org/html/rfc6901).
## CLI
Looking to filter JSON from the command line? Check out [jsonpointer-cli](https://github.com/joeyespo/jsonpointer-cli).
## Usage
```javascript
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 undefinedjsonpointer.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
$ npm test
All tests pass.
$[![Node.js CI](https://github.com/janl/node-jsonpointer/actions/workflows/node.js.yml/badge.svg)](https://github.com/janl/node-jsonpointer/actions/workflows/node.js.yml)
## Author
(c) 2011-2021 Jan Lehnardt & Marc Bachmann
Thanks to all contributors.
## License
MIT License.