Folks, I have the following JSON object, in which I would like to recursively find every occurrence of foo with bar.
Also the [Object] can potentially contain foo which would also need to be replaced.
{ _id: 530797d8952e10129f97fde3,
Product: 'something',
Realm: [ 'something', 'something','foo' ],
Service: 'Node',
Owners: [ 'foo', 'something' ],
Project: 'something',
URLs:
[ { 'foo': [Object] },
{ 'foo': [Object] },
{ 'foo': [Object] } ] }
How would i loop through this? I've tried with but failed:
var cleanObject = {}
for (key in dirtyObject) {
key = key.replace('foo', 'bar');
cleanObject[key] = dirtyObject[key];
}