Skip to content

About

An RFC-6901 JSON Pointer implementation

Resources

Stars

8 stars

Watchers

1 watching

Forks

Repository files navigation

Hyperjump - JSON Pointer

An implementation of RFC 6901 JSON Pointer. Get, set, and remove values in a JSON document by pointer, and build and split pointers without escaping them by hand.

Read the documentation at hyperjump.io

npm install @hyperjump/json-pointer
import { pointerGet, pointerSet } from "@hyperjump/json-pointer";

const doc = { foo: { bar: 42 } };

pointerGet("/foo/bar", doc); // 42

const updated = pointerSet("/foo/bar", doc, 33);
updated.foo.bar; // 33
doc.foo.bar; // 42
  • Immutable or in place. pointerSet and pointerUnset return a new value and leave the original alone. pointerAssign and pointerRemove change it in place.
  • Parse once, apply many times. Give a function only a pointer, and it returns a function you can apply to any number of documents.
  • Escaping handled. pointerAppend, pointerParse, and pointerStringify escape and unescape ~ and / for you.
  • Small. No dependencies. TypeScript types included. Works in Node.js and browsers.

Documentation

Using v1? See the v1 README.

Contributing

Tests

Run the tests

npm test

Run the tests with a continuous test runner

npm test -- --watch

Lint and type-check

npm run lint
npm run type-check

Docs

The user documentation is in website/, and it's published to hyperjump.io. The design docs, principles, and style guide are in design/.

About

An RFC-6901 JSON Pointer implementation

Resources

Stars

8 stars

Watchers

1 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages