Created
November 30, 2010 13:28
-
-
Save Wizek/721671 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
function setNestedJSON (path, value, obj, separator) { | |
console.log(obj) | |
separator = separator || "-" | |
obj = obj || {} | |
if (typeof path != 'object') {path = path.split(separator)} | |
if (path.length == 1) { | |
obj[path] = value | |
}else{ | |
obj[path[0]] = arguments.callee(path.slice(1), value, obj[path[0]]) | |
}; | |
return obj | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment