From a http request, a blob (b) (type application/octet-stream) is downloaded and then needs to be processed, it contains a json object.
I tried the following:
var reader = new FileReader();
reader.readAsText(b);
var readResult = <string> reader.result;
console.log(readResult);
var obj = JSON.parse(readResult);
It doesn´t work, and readResult is null.
How can you process a blob that contains a json into a json object?
readAsText
is asynchronous. You need to listen to theloadend
event. See developer.mozilla.org/en-US/docs/Web/API/FileReader/readAsText – Citrate