Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

384
Views
How can I read a Blob object in Javascript as JSON object
let file = new Blob([response.data], {type: 'application/json'});

response.data contains JSON file, I want to read the contents of this file and assign them as a JSON string to a variable in javascript.

I've tried a few things with FileReader.readAsText(file) but I'm not able to properly convert it into a simple JSON string.

P.S.: The response.data is an arraybuffer, so if there's a direct conversion that's possible without creating a Blob object, that should also solve the problem.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

let file = new Blob([response.data], {type: 'application/json'});

file.text()
        .then(value => {
           self.objectName = JSON.parse(value);
           console.log(self.objectName);
         })
         .catch(error => {
           console.log("Something went wrong" + error);
         });

Did the trick for me.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!