Possible Duplicate:
Accessing property of object with variable
How do I add a property to a JavaScript object using a variable as the name?
I'm trying to achieve the following, push an anonymous object into an array, but using the variable 'name' as the Object key. Any ideas how I could achieve this?
var json = $('form[name="edit-form"]').serializeArray();
var data = {};
data.user = [];
var l = json.length;
for(var i = 0; i < l; i++){
var name = json[i].name;
var value = json[i].value;
data.user.push({[name]: value});
}