Consider the following JSON array:
_htaItems = [
{"ID":1,
"parentColumnSortID":"0",
"description":"Precondition",
"columnSortID":"1",
"itemType":0},
{"ID":2,
"parentColumnSortID":"0",
"description":"Precondition",
"columnSortID":"1",
"itemType":0}]
The goal is to update this array by providing the ID, column name, and new value as parameters to a function:
function updateJSON(ID, columnName, newValue)
{
var i = 0;
for (i = 0; i < _htaItems.length; i++)
{
if (_htaItems[i].ID == ID)
{
?????
}
}
}
The main question is how to perform the update. Typically, one could simply assign a new value like so:
_htaItems[x].description = 'New Value'
However, in this case, the column name is provided as a string.