File API – Blob to JSON

You should have tried readAsText() instead of readAsArrayBuffer() (JSON is text in the end).

You’ve also missed to stringify the object (convert to JSON text)

var b = new Blob([JSON.stringify({"test": "toast"})], {type : "application/json"}),
    fr = new FileReader();

fr.onload = function() {
    console.log(JSON.parse(this.result))
};

fr.readAsText(b);

Leave a Comment