3.1.1 • Published 5 years ago

js-pointer v3.1.1

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

js-pointer

Greenkeeper badge Build Status Coverage Status Dependencies npm version

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 --save

Point 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')
// → 3

Pointing through array elements

const object = { one: { two: [{ three: 4 }] } }
jsPointer.get(object, '/one/two/0/three')
// → 4

Please 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.

3.1.1

5 years ago

3.1.0

5 years ago

3.0.1

6 years ago

3.0.0

6 years ago

2.1.0

7 years ago

2.0.2

7 years ago

2.0.1

8 years ago

2.0.0

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago