title: How to convert string to a object in typescript
body: <p>I am making dynamic forms in Angular 6 . For that i am sending JSON from backend . PFB the json</p>
  
  <hr>
  
  <pre><code>[
   {
    "controlType": "input",
    "label": "Test1",
    "key": "some1",
    "value": "This input is pre-populated",
    "syncValidators": "Validators.required"
   }
  ]
  </code></pre>
  
  <hr>
  
  <p>I am making the forms in Typescript as follows. PFB the code</p>
  
  <pre><code>this.dataList = JSON.parse(event.body); //Contains the JSON sent from backend
  const formContent: any = {};
  
  this.dataList.forEach(data =&gt; { 
        formContent[data.key] = new FormControl(data.value ,data.syncValidators));
   });
  
  this.exampleForm = new FormGroup(formContent);
  </code></pre>
  
  <p>I am getting the problem in => data.syncValidators , as it is treated as a string . But it needs to be Validators.required .</p>
  
  <p>How can i make the conversion so that 'data.syncValidators' will be taken as a method not as a string ?</p>