An open API service indexing awesome lists of open source software.

https://github.com/azer/get-object-path

Return the value at given object path.
https://github.com/azer/get-object-path

Last synced: 11 months ago
JSON representation

Return the value at given object path.

Awesome Lists containing this project

README

          

## get-object-path

Return the value at given object path.

## Install

```bash
$ npm install azer/get-object-path
```

## Usage

```js
var get = require('get-object-path')

var context = {
foo: 'bar',
qux: {
hello: 'world',
eggs: [
'white egg',
'brown egg'
],
'delicious fruits :)': [
'grape',
'orange',
'carrot'
]
}
}

get(context, 'foo')
// => 'bar'

get(context, 'qux.hello')
// => world

get(context, 'qux.eggs[0]')
// => white egg

get(context, 'qux.eggs[1]')
// => brown egg

get(context, 'qux.delicious fruits :)[1]')
// => orange
```

See `test.js` for more info.