# rspath

> A small simple library to easily get/set/delete items from JSON objects based on a path.

Latest version **1.0.2** (published 2019-05-02) · ISC license · 0 weekly downloads

## Install

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

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2019-05-02 |
| First published | 2016-06-16 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 17.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Rich Somerfield |
| Maintainers | richie5um |
| Keywords | json, path, patch, update |

## Links

- npm: https://www.npmjs.com/package/rspath
- Repository: https://github.com/richie5um/rspath
- Homepage: https://github.com/richie5um/rspath#readme
- Issues: https://github.com/richie5um/rspath/issues
- npm.io page: https://npm.io/package/rspath

## Dependencies (1)

- [underscore](https://npm.io/package/underscore.md) ^1.8.3

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.0.2 (latest) — 2019-05-02
- 1.0.1 — 2016-06-16
- 1.0.0 — 2016-06-16

## README

# RSPath

A small simple library to easily get/set/delete items from JSON objects based on a path.

## Installation

    npm install rspath --save

## Usage

    var rspath = require('rspath');

    // Simple

    var obj = {
        a: true
    };

    console.log(rspath.pathGet(obj, 'a'));

    rspath.pathSet(obj, 'a', false);
    console.log(rspath.pathGet(obj, 'a'));

    rspath.pathSet(obj, 'a', { hello: 'world' });
    console.log(rspath.pathGet(obj, 'a'));

    rspath.pathDelete(obj, 'a.hello');
    console.log(rspath.pathGet(obj, 'a.hello'));

    console.log(rspath.pathGet(obj, 'a'));

    // Arrays

    obj = {
        a: true,
        b: {
            ba: [],
            bb: [0, 1, 2, 3, 4]
        }
    };

    console.log(rspath.pathGet(obj, 'b'));
    console.log(rspath.pathGet(obj, 'b.bb'));
    console.log(rspath.pathGet(obj, 'b.bb[0]'));
    console.log(rspath.pathGet(obj, 'b.bb[1]'));
    console.log(rspath.pathGet(obj, 'b.bb[2]'));
    console.log(rspath.pathGet(obj, 'b.bb[3]'));
    console.log(rspath.pathGet(obj, 'b.bb[4]'));
    console.log(rspath.pathGet(obj, 'b/bb[4]', '/'));

    // Arrays and Objects

    obj = {
        a: true,
        b: {
            ba: [{
                baa: [0, 1, 2, 3, 4]
            }, {
                bab: [0, 1, 2, 3, 4]
            }]
        }
    };

    console.log(rspath.pathGet(obj, 'b'));
    console.log(rspath.pathGet(obj, 'b.ba[0].baa[3]'));
    console.log(rspath.pathGet(obj, 'b.ba[1].bab[4]'));
    console.log(rspath.pathGet(obj, 'b.ba[1].bab[5]'));
    console.log(rspath.pathGet(obj, 'b.ba[2]'));
    console.log(rspath.pathGet(obj, 'b.ba[2].bac[4]'));

## Tests

    npm test

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