Skip to content

vigneshkv23/complex-json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Access the deep objects inside an object with ease.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published