title: How to remove empty object from JSON recursively using lodash
body: <pre><code>var template = {
      personal: {},
      education: {},
      certificate: [{"test": "Test"}, {}, {}],
      experience: []
  }
  
  removeEmptyObj(template);
  
  function removeEmptyObj(obj)
  for (var key in obj) {
      console.log("Foor Loop" + key + " " + obj[key]);
      if (_.isObject(obj[key]) &amp;&amp; !_.isEmpty(obj[key])) {
          console.log("Second Loop Object:::" + key + " " + obj[key]);
          removeEmptyObj(obj[key]);
      }
      if (_.isEmpty(obj[key])) {
          console.log("Delete Object:::" + key + " " + obj[key]);
          obj = _.omitBy(obj, _.isEmpty);
      }
  }
  console.log(obj);
  return obj;
  }
  </code></pre>
  
  <p>Current Output is : <code>{certificate: [{"test": "Test"}, {}, {}]}</code></p>
  
  <p>Desired Output :  <code>{certificate: [{"test": "Test"}]}</code></p>
  
  <p>What's wrong here your help appreciate :) </p>