When using the file upload function to upload a json file and read its contents, I am encountering an issue where the result is in string format instead of object. How can I display it as an object?
Here is my code:
.html
<div class="form-group">
<input type="file" (change)="filechanged($event)" />
</div>
.ts
filechanged(e){
this.file = e.target.files[0];
this.uploadDocument(this.file);
}
uploadDocument(file){
let fileReader = new FileReader();
fileReader.onload =(e) => {
this.Name = fileReader.result;
console.log(typeof this.Name);
};
fileReader.readAsText(this.file);
}
I am currently receiving the output as a string rather than an object.