Created
May 15, 2015 06:28
-
-
Save Yonet/4b6eacbdba8bf3b35fea to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var flatten = function(obj, cKey, returnObj) { | |
result = returnObj || {}; | |
for(var key in obj) { | |
var newKey = cKey ? cKey + '.'+ key : key; | |
if(!(obj[key] instanceof Object)) { | |
result[newKey] = obj[key]; | |
} | |
else if (obj[key] instanceof Object){ | |
flatten(obj[key], newKey, result); | |
} | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment