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