I'm trying to push an object inside an array with dynamic attribute name.
Let's say we have the following variables defined
myJSON = {"students" : [ {"name":"Your Name"}, {"name":"My Name"} ] };
attribName = "name";
myValue = "myValue";
parsedJSON = JSON.parse(myJSON);
parsedJSON["students"].push({attribName : myValue});
myJSON = JSON.stringfy(parsedJSON);
The example isn't working. Is there a way to push an object with dynamic attribute name?