title: ReactiveForms in Angular 2 generate JSON with empty value or empty object for my optional field
body: <p>I have an issue with reactive forms in angular 2. I want to create my object to send it to my API but my ReactiveForms generate also no required field and formgroup.</p>
  
  <p>If I send directly my object thanks to http post request I have this JSON :</p>
  
  <pre><code>MyObject{
  Name:"toto"
  Surname:""
     Address:{
      City:"",
      StreetName:""
     }
  }
  </code></pre>
  
  <p>But I want this JSON to agree with the API. (If there is empty or null property/object I obtain an error because the fields are present but not valid:</p>
  
  <pre><code>MyObject{
  Name:"toto"
  }
  </code></pre>
  
  <p>Because Surname and Address is optionnal.</p>
  
  <p>I use ReactiveForm with formBuilder and I do not know how I can obtain only fill fields.</p>
  
  <p>This how I create my form :</p>
  
  <pre><code>myForm: FormGroup;
  myUserModel : UserModel; // (Interface UserModel such as my form fields)
  
  constructor(private fb : FormBuilder){}
  
  createForm(){
     this.myFrom = this.fb.FormGroup({
        Name:['';Validators.requires],
        Surname:'',
        Address:this.fb.FormFroup({
            City: '',
            StreetName:''
        })
     })
  }
  
  onSubmit(){
      this.myUserModel = this.myForm.value;
      this.registerUserToAPI(this.myUserModel);
  }
  </code></pre>
  
  <p>To cheat I use this but it's so dirty... :</p>
  
  <pre><code>cleanObjectToSend(obj){
      return this.removeEmptyObj(this.removeEmptyAttribute(obj));
    }
  
    removeEmptyAttribute = (obj) =&gt; {
      Object.keys(obj).forEach(key =&gt; {
        if (obj[key] &amp;&amp; typeof obj[key] === 'object') this.removeEmptyAttribute(obj[key]);
        else if (obj[key] == null || obj[key] == '') delete obj[key];
      });
      return obj;
    };
  
    removeEmptyObj(obj){
      Object.keys(obj).forEach(key =&gt; {
        if (obj[key] &amp;&amp; typeof obj[key] === 'object') {
          if(Object.keys(obj[key]).length===0 &amp;&amp; obj[key].constructor == Object){
            delete obj[key];
            return;
          }
          else this.removeEmptyObj(obj[key]);
        }
        else if (obj[key] == null || obj[key] == '') delete obj[key];
      });
      return obj;
  
    }
  </code></pre>
  
  <p>It allow me to obtain only not null and not empty field to generate my JSON then.</p>
  
  <p>How can I have a JSON clean JSON directly without null or empty value ?</p>