I have an object like this
{"first":["first 1"],"second":["second 1","second 2"],"third":["third 1", "third 2"]}
I want to be able to change a property name based on a variable value. If the variable is "second" it should change the property second to whatever i want. I have tried some methods...
This
object[theVariable] = "new second";
Will change the value of the property to this
{"first":["first 1"],"second":"new second","third":["third 1", "third 2"]}
And this
object.theVariable = "new second";
Will create a new property like this
{"first":["first 1"],"second":["second 1","second 2"],"third":["third 1", "third 2"],"theVariable":"new second"}
None of these methods change the property "second" to "new second" when "second" is stored in the variable "theVariable"
Desired result:
{"first":["first 1"],"new second":["second 1","second 2"],"third":["third 1", "third 2"]}
How can this be done?