https://github.com/ragingwind/picker
Pick property in json data by string path key
https://github.com/ragingwind/picker
Last synced: about 1 year ago
JSON representation
Pick property in json data by string path key
- Host: GitHub
- URL: https://github.com/ragingwind/picker
- Owner: ragingwind
- License: mit
- Created: 2015-04-29T00:28:27.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2015-04-29T02:50:43.000Z (about 11 years ago)
- Last Synced: 2025-04-09T04:24:49.436Z (about 1 year ago)
- Language: JavaScript
- Size: 129 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# picker [](https://travis-ci.org/ragingwind/picker)
> Pick property in json data by string path key
## Install
```
$ npm install --save picker
```
## Usage
```js
var picker = require('picker');
var prop = picker(json, 'json.properties.object.name');
console.log(prop.value, prop.key, prop.container);
var prop = picker(json, 'json.properties.array.[0]');
console.log(prop.container[0]);
```
## API
### picker(jsonData, path)
#### input
*Required*
Type: `json`
Target json data contains name and value to pick
#### path
*Required*
Type: `string`
Path to get to target property. Using string index to get a path to `Array` type property. You can find more information in the test.js
## Returns
If picker can find a target then will returns its parent, key and value of object or not picker returns null.
## License
MIT © [ragingwind](http://ragingwind.me)