# jsonpointer

> Simple JSON Addressing.

Latest version **5.0.1** (published 2022-07-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install jsonpointer
pnpm add jsonpointer
yarn add jsonpointer
bun add jsonpointer
```

## Health

**Score 35/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 5.0.1 |
| Published | 2022-07-13 |
| First published | 2011-07-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=0.10.0 |
| Dependencies | 0 |
| Unpacked size | 6.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 197 |
| Author | Jan Lehnardt |
| Maintainers | jan, marcbachmann |

## Links

- npm: https://www.npmjs.com/package/jsonpointer
- Repository: https://github.com/janl/node-jsonpointer
- Homepage: https://github.com/janl/node-jsonpointer#readme
- Issues: http://github.com/janl/node-jsonpointer/issues
- npm.io page: https://npm.io/package/jsonpointer

## Recent versions

- 5.0.1 (latest) — 2022-07-13
- 5.0.0 — 2021-10-31
- 4.1.0 — 2020-07-03
- 4.0.1 — 2016-12-21
- 4.0.0 — 2016-05-19
- 3.0.1 — 2016-05-19
- 3.0.0 — 2015-09-29
- 2.0.0 — 2015-05-26
- 1.1.0 — 2013-01-20
- 1.0.1 — 2011-07-31
- 1.0.0 — 2011-07-13

## README

# JSON Pointer for Node.js

This is an implementation of [JSON Pointer](https://tools.ietf.org/html/rfc6901).

## CLI

Looking to filter JSON from the command line? Check out [jsonpointer-cli](https://github.com/joeyespo/jsonpointer-cli).

## Usage
```javascript
var jsonpointer = require('jsonpointer');
var obj = { foo: 1, bar: { baz: 2}, qux: [3, 4, 5]};

jsonpointer.get(obj, '/foo');     // returns 1
jsonpointer.get(obj, '/bar/baz'); // returns 2
jsonpointer.get(obj, '/qux/0');   // returns 3
jsonpointer.get(obj, '/qux/1');   // returns 4
jsonpointer.get(obj, '/qux/2');   // returns 5
jsonpointer.get(obj, '/quo');     // returns undefined

jsonpointer.set(obj, '/foo', 6);  // sets obj.foo = 6;
jsonpointer.set(obj, '/qux/-', 6) // sets obj.qux = [3, 4, 5, 6]

var pointer = jsonpointer.compile('/foo')
pointer.get(obj)    // returns 1
pointer.set(obj, 1) // sets obj.foo = 1
```

## Testing

    $ npm test
    All tests pass.
    $

[![Node.js CI](https://github.com/janl/node-jsonpointer/actions/workflows/node.js.yml/badge.svg)](https://github.com/janl/node-jsonpointer/actions/workflows/node.js.yml)

## Author

(c) 2011-2021 Jan Lehnardt <jan@apache.org> & Marc Bachmann <https://github.com/marcbachmann>

Thanks to all contributors.

## License

MIT License.

---
_Source: https://npm.io/package/jsonpointer · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
