get-value
Use property paths (a.b.c
) to get a nested value from an object.
Install
Install with npm
$ npm i get-value --save
Install with bower
$ bower install get-value --save
Usage
var get = require('get-value');
var obj = {a: {b : {c: {d: 'foo'}}}, e: [{f: 'g'}]};
get(obj, 'a.b.c');
get(obj, 'a.b.c.d');
get(obj, 'e[0].f');
key as an array
Optionally pass the key as an array (this is useful when you need to dynamically build up the property name)
var obj = {a: {b: 'c'}};
get(obj, ['a', 'b']);
Related projects
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Running tests
Install dev dependencies:
$ npm i -d && npm test
Author
Jon Schlinkert
License
Copyright © 2014-2015 Jon Schlinkert
Released under the MIT license.
This file was generated by verb-cli on October 29, 2015.