I've a large JSON string describing some data. I'd like to loop through this and replace value of all properties named "Key". How can I achieve this using jQuery or plain Javascript?
var item = $.parseJson("jsonstring...");
var target = "Key";
for (var k in item) {
if (item.hasOwnProperty(k) && item[k].hasOwnProperty(target)) {
item[k][target] = "replacement value"
}
}
Or similar, depending on the structure of your JSON. This is assuming it's a list of objects.