title: Parsing selected file to array in Angular
body: <p>I am trying to parse a selected file into an object array in Angular 7.</p>
  
  <p>HTML where I select the file:</p>
  
  <pre><code>&lt;div class="form-group" *ngIf="import"&gt;
    &lt;label for="file"&gt;Choose backup file&lt;/label&gt;
    &lt;input type="file" id="file" (change)="handleFileInput($event.target.files)"&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I am already able to log the the values from the file using this code snippet:</p>
  
  <pre><code>fileToUpload: File = null;
  handleFileInput(files: FileList) {
      this.fileToUpload = files.item(0);
      this.parseFile();
  }
  
  parseFile() {
    const fileReader = new FileReader();
  
    fileReader.onload = (e) =&gt; {
      console.log(fileReader.result);
    }
  
    fileReader.readAsText(this.fileToUpload);
  }
  </code></pre>
  
  <p>The file always is a json file containing an array of objects like this:</p>
  
  <pre><code>[
      {"Test": "ValueA", "Value": "SomeStringA"},
      {"Test": "ValueB", "Value": "SomeStringB"},
      ...
  ]
  </code></pre>
  
  <p>My goal is to deserialize into an object array <code>ObjectA[]</code> for the following object:</p>
  
  <pre><code>export interface ObjectA {
      Test: string;
      Value: string;
  }
  </code></pre>
  
  <p>Can someone help me how to go on with filereader to achieve this?</p>
  
  <p>Many thanks in advance</p>