Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

381
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda