Package Exports
- js-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 (js-pointer) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
js-pointer
Tiny, spec compliant implementation of the JSON Pointer spec RFC 6901 with 100% test coverage and no dependencies.
Getting started
Install via NPM
npm i js-pointer --savePoint to object properties
const jsPointer = require('js-pointer');
const object = { one: { two: 3 } }
jsPointer.get(object, '/one/two')
// → 3
Pointing to array elements
const object = { one: { two: [3] } }
jsPointer.get(object, '/one/two/0')
// → 3Pointing through array elements
const object = { one: { two: [{ three: 4 }] } }
jsPointer.get(object, '/one/two/0/three')
// → 4Please see the spec and tests for further detail of the JSON pointer format.
API
jsPointer.get(object, pointer)
Returns sub-object or value in object referred to by pointer.
If pointer does not refer to an object or value then undefined will be returned.
object
Plain object targeted by the pointer
pointer
string JSON pointer. A pointer beginning with # indicates a URI fragment, which will be URI decoded before processing.