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-pointerimport { 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.
pointerSetandpointerUnsetreturn a new value and leave the original alone.pointerAssignandpointerRemovechange 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, andpointerStringifyescape and unescape~and/for you. - Small. No dependencies. TypeScript types included. Works in Node.js and browsers.
Using v1? See the v1 README.
Run the tests
npm testRun the tests with a continuous test runner
npm test -- --watchLint and type-check
npm run lint
npm run type-checkThe user documentation is in website/, and it's
published to hyperjump.io. The design
docs, principles, and style guide are in design/.