Skip to content

Latest commit

 

History

History
24 lines (17 loc) · 545 Bytes

README.md

File metadata and controls

24 lines (17 loc) · 545 Bytes

json-rename-keys

A Node.js module that allows to rename object keys and the nested ones.

#Simple example

var rename = require('json-rename-keys');
var jsonobject = {"sn":{"sn":{"sn":"nested key","s3":"hi"},"s2":{"s22":"coucou","sn":"nested key"}},"s1":{"sn":"nested key"}};

rename(jsonobject, function(key){
    switch(key) {
    	case "sn" : return "cn";
    }
});

#result :

{"cn":{"cn":{"cn":"nested key","s3":"hi"},"s2":{"s22":"coucou","cn":"nested key"}},"s1":{"cn":"nested key"}}