complex-json

0.1.4 • Public • Published

Welcome to complex-json 👋

Version Documentation License: MIT Twitter: vigneshkv23

Access the deep objects inside an object with ease.

Install

npm install complex-json -save

Api

get - returns value
set - returns JSON
del - returns JSON
has - returns Boolean 
getPath - returns path in array format

Usage:

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

🤝 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 ❤️

Package Sidebar

Install

npm i complex-json

Weekly Downloads

5

Version

0.1.4

License

MIT

Unpacked Size

17.3 kB

Total Files

11

Last publish

Collaborators

  • vigneshkv23