Accessing or creating nested JavaScript objects with string key without eval
You could split the path and reduce the path by walking the given object. If no Object exist, create a new property with the name, or an array. Later assign the value. function setValue(object, path, value) { var way = path.replace(/\[/g, ‘.’).replace(/\]/g, ”).split(‘.’), last = way.pop(); way.reduce(function (o, k, i, kk) { return o[k] = … Read more