Package Exports
- json8-pointer
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (json8-pointer) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
JSON8 Pointer
JSON Pointer RFC 6901 implementation for JavaScript.
See also JSON8 Patch for more methods to work with JSON pointers.
Getting started
npm install json8-pointer
var ooPointer = require('json8-pointer');or
<script src="node_modules/json8-pointer/JSON8Pointer.js"></script>var ooPointer = window.JSON8PointerMethods
find
Use a JSON Pointer to find a value in a JSON document.
Returns undefined if the value cannot be found.
var doc = {"foo": {"bar": "foobar"}}
ooPointer.find(doc, '/foo/bar');
// "foobar"
ooPointer.find(doc, '/bar/foo');
// undefinedparse
Takes a JSON Pointer string and return an array of unescaped tokens.
ooPointer.parse('/foo/bar/hello');
// ['foo', 'bar', 'hello'];
ooPointer.parse('/foo/a~1b')
// ['foo', 'a/b']You can specify a different separator than the default /.
ooPointer.parse('.foo.bar.hello', '.');
// ['foo', 'bar', 'hello'];serialize
Takes an array of escaped tokens (see parse) and return a JSON Pointer string.
ooPointer.serialize(['foo', 'bar', 'hello']);
// '/foo/bar/hello'
ooPointer.serialize(['foo', 'a/b'])
// '/foo/a~1b'You can specify a different separator than the default /.
ooPointer.parse(['foo', 'bar', 'hello'], '.');
// '.foo.bar.hello'Tests
npm install -g eslint mocha babel
npm test
Contributing
See CONTRIBUTING.md