Package Exports
- complex-json
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (complex-json) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Welcome to complex-json 👋
Access the deep objects inside an object with ease.
Install
npm install complex-json -saveApi
get - returns value
set - returns JSON
del - returns JSON
has - returns Boolean
getPath - returns path in array formatUsage:
var json = {
"a": {
"b": [{
"c":"value",
"d":"val"
}],
"b1": [{
"c":"value",
"d1":"val"
}]
}
}
var complexJson = require('complex-json');
// If key is duplicate in any section,It is mandatory pass the third param which is the parent key
// If parent key is not passed & duplicate key is present-returns undefied
complexJson.set(json, 'c', 'newValue' ,'b'); // returns modified json
//set accepts key,value in array-can be used to set/change multiple keys at a time
var keys=['c','d1'];
var values=['new-c-value','new-d1-value']
var parentKeys=['b','b1']
complexJson.set(json, keys, values ,parentKeys); // returns modified json
complexJson.has(json, 'c' ,'b'); // returns true
complexJson.del(json, 'c' ,'b'); // returns modified json
// If parentKey passed returns specific value/path, If not returns every matched value/path
complexJson.get(json, 'c', 'b'); // returns 'value'
complexJson.getPath(json, 'c' ,'b'); // returns array Author
👤 vignesh
- Twitter: @vigneshkv23
- Github: @vigneshkv23
- LinkedIn: @vigneshkv23
🤝 Contributing
Contributions, issues and feature requests are welcome!
Feel free to check issues page.
Show your support
Give a ⭐️ if this project helped you!
complex-json developed with ❤️