Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

388
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda