Skip to content

Instantly share code, notes, and snippets.

@Wizek
Created November 30, 2010 13:28
Show Gist options
  • Save Wizek/721671 to your computer and use it in GitHub Desktop.
Save Wizek/721671 to your computer and use it in GitHub Desktop.
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