JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 5284
  • Score
    100M100P100Q133775F
  • License MIT

JSON Pointer implementation for JavaScript

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

build status

JSON Pointer RFC 6901 implementation for JavaScript.

See also JSON8 Patch for more methods to work with JSON Pointer.

Getting started

npm install json8-pointer

var JSONPointer = require('json8-pointer');

or

<script src="node_modules/json8-pointer/JSON8Pointer.js"></script>
var JSONPointer = window.JSON8Pointer

Methods

find

Use a JSON Pointer to find a value in a JSON document.

var doc = {"foo": {"bar": "foobar"}}
JSONPointer.find(doc, '/foo/bar');
// "foobar"

parse

Takes a JSON Pointer string and return an array of unescaped tokens.

JSONPointer.parse('/foo/bar/hello');
// ['foo', 'bar', 'hello'];

JSONPointer.parse('/foo/a~1b')
// ['foo', 'a/b']

serialize

Takes an array of escaped tokens (see parse) and return a JSON Pointer string.

JSON8.serialize(['foo', 'bar', 'hello']);
// '/foo/bar/hello'

JSONPointer.serialize(['foo', 'a/b'])
// '/foo/a~1b'

Tests

npm install -g eslint mocha babel
npm test

Contributing

See CONTRIBUTING.md