我有以下 JSON 对象
{
"class": "go.GraphLinksModel",
"nodeDataArray": [{
"key": "CTR:2",
"type": "Controller",
"devicename": "ACU-1K",
"deviceid": "2",
"imageUrl": "http://localhost:52233/Images/ComputerSpeaker_32.png",
"loc": "280 112"
}, {
"key": "CTR:1",
"type": "Controller",
"devicename": "C302-1",
"deviceid": "1",
"imageUrl": "http://localhost:52233/Images/ComputerSpeaker_32.png",
"loc": "477 92"
}, {
"key": "RDR:25",
"type": "Reader",
"devicename": "1K-1-RDR01",
"deviceid": "25",
"imageUrl": "http://localhost:52233/Images/Plugin_32.png",
"loc": "592 41"
}],
"linkDataArray": []
}
我想遍历nodeDataArray,并为nodeDataArray中的每个项目更改imageUrl的值
我试过这个,但它不起作用
$.each(jsonCoordinates, function(key, value) {
var nodeData = value.nodeDataArray;
$.each(nodeData, function(k, v) {
v.imageUrl = "default";
});
});
应该如何?
jsonCoordinates
包含上面的整个 JSON 块