# objectpath

> Parse js object paths using both dot and bracket notation. Stringify an array of properties into a valid path.

Latest version **2.0.0** (published 2020-01-21) · MIT license · 0 weekly downloads

## Install

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

## 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 | 2.0.0 |
| Published | 2020-01-21 |
| First published | 2014-07-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 16.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 64 |
| Author | Mike Marcacci |
| Maintainers | mike-marcacci |
| Keywords | js object, dot notation, bracket notation, path, parse, string, object path, object |

## Links

- npm: https://www.npmjs.com/package/objectpath
- Repository: https://github.com/mike-marcacci/objectpath
- Issues: https://github.com/mike-marcacci/objectpath/issues
- npm.io page: https://npm.io/package/objectpath

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 2.0.0 (latest) — 2020-01-21
- 1.2.2 — 2018-11-09
- 1.2.1 — 2015-06-01
- 1.2.0 — 2015-06-01
- 1.1.0 — 2014-11-13
- 1.0.5 — 2014-07-28
- 1.0.1 — 2014-07-26
- 1.0.0 — 2014-07-26
- 0.0.3 — 2014-07-26

## README

ObjectPath
==========

[![Join the chat at https://gitter.im/mike-marcacci/objectpath](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/mike-marcacci/objectpath?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

[![Build Status](https://travis-ci.org/mike-marcacci/objectpath.svg?branch=master)](https://travis-ci.org/mike-marcacci/objectpath)

Parse js object paths using both dot and bracket notation. Stringify an array of properties into a valid path.

- parse JS object reference fragments
- build JS object reference fragments
- supports presence of unicode characters
- supports presence of control characters in key names

Parse a Path
------------

ObjectPath.parse(str)

```js
var ObjectPath = require('objectpath');

ObjectPath.parse('a[1].b.c.d["e"]["f-f"].g');
// => ['a','1','b','c','d','e','f-f','g']
```

Build a Path String
-------------------

ObjectPath.stringify(arr, [quote="'"], [forceQuote=false]);

```js
var ObjectPath = require('objectpath');

ObjectPath.stringify(['a','1','b','c','d-d','e']);
// => "a[1].b.c['d-d'].e"


ObjectPath.stringify(['a','1','b','c','d-d','e'],'"');
// => 'a[1].b.c["d-d"].e'


ObjectPath.stringify(['a','1','b','c','d-d','e'],"'", true);
// => "['a']['1']['b']['c']['d-d']['e']"
```

Normalize a Path
----------------

ObjectPath.normalize(str, [quote="'"], [forceQuote=false])

```js
var ObjectPath = require('objectpath');

ObjectPath.normalize('a[1].b.c.d["e"]["f-f"].g');
// => "a[1].b.c.d.e['f-f'].g"

ObjectPath.normalize('a[1].b.c.d["e"]["f-f"].g', '"');
// => 'a[1].b.c.d.e["f-f"].g'

ObjectPath.normalize('a[1].b.c.d["e"]["f-f"].g', "'", true);
// => "['a']['1']['b']['c']['d']['e']['f-f']['g']"

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