knife-json

1.0.2 • Public • Published

knife-json

Get value of object easily use path

building

NOTE: not supprt the array current

API

  1. knife(object, path) => Get the value of the path
  2. knife.paths(object) => get the paths of the object
  3. knife.contain(object, path) => check the paths of the object
var knife = require('knife-json');

var testdata = {
  root: 'root',
  name: 'yt',
  nested: {
    nested1: {
      nested2: "nested3"
    }
  }
};

console.log(knife(testdata, 'nested.nested1.nested2')) // nested3
console.log(knife.paths(testdata)) // [ 'root', 'name', 'nested.nested1.nested2' ]
console.log(knife.contain(testdata, 'nested.nested1.nested2')) //true

Dependents (0)

Package Sidebar

Install

npm i knife-json

Weekly Downloads

0

Version

1.0.2

License

ISC

Last publish

Collaborators

  • yt_fan