json-path-search
v1.0.5
Published
A simple utility for traversing a JSON object using relative paths
Downloads
12
Maintainers
Readme
json-path-search
A simple utility for traversing a JSON object using relative paths.
Sample Code Snippet:
const search = require('json-path-search');
const object = {
key1: {
key2: {
key3: 'value'
}
}
};
console.log(search(object, "/")); // { key1: { key2: { key3: 'value' } } }
console.log(search(object, "/key1/key2")); // { key3: 'value' }
console.log(search(object, "/key1/key2/key3")); // 'value'
console.log(search(object, "/key1/key2/errorKey")); // undefined
console.log(search(object, "/key1/key2/errorKey1/errorKey2")); // undefined