我需要更新 JSON 中的值。
我的 JSON 结果如下所示:
results = {"ROWCOUNT":50,"COLUMNS":["PERSONID","NAME"],"DATA":{"PERSONID":["42","43","44"], "NAME":["JOE","TOM","JANE"]}
resultData = results.DATA
在下面的代码中,我循环遍历结果集并尝试更新某个位置的值。我相信它失败了,因为我没有正确使用动态变量。
var columnName = "NAME";
for(i=0; i < results.ROWCOUNT; i++ ){
resultData.columnName[i] = "foo" // failing here due to "columnName" being dynamic.
}