1function getObjects(obj, key, val, newVal) {
2 for (var i in obj) {
3 if (!obj.hasOwnProperty(i)) continue;
4 if (i == key && obj[key] == val) {
5 obj[key] = newVal;
6 }
7 }
8 return obj
9}
10
1function getObjects(obj, key, val, newVal) {
2 var newValue = newVal;
3 var objects = [];
4 for (var i in obj) {
5 if (!obj.hasOwnProperty(i)) continue;
6 if (typeof obj[i] == 'object') {
7 objects = objects.concat(getObjects(obj[i], key, val, newValue));
8 } else if (i == key && obj[key] == val) {
9 obj[key] = 'qwe';
10 }
11 }
12 return obj;
13}
14