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

310
Visualizações
Where to check Javascript's JSON.parse() error log on dev-tools?

I am new to Javascript trying to create a project that uses JSON.parse() function. My code runs successfully however JSON.parse dint work and didn't return any error on the dev tools console log.

I tried to debug my code with:

console.log("Test log1#######")
console.log(JSON.parse(json));
console.log("Test log2#######") 

On the console.log i can only see "Test log1#######". but not the "Test log2#######" which means code fails at line two but without printing any error on Devtools console as it does normally. But I am sure the code is failing due to some JSON validation issue but I can't see the. error anywhere on dev tools.

Please suggest a method to explore the error log of JSON.parse()

thanks

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You can do :

try{
  JSON.parse(badFormat);
}catch(err){
  console.log(err);
}
about 4 years ago · Juan Pablo Isaza Relatório

0

Most probably your "json" string is undefined

Try using the reviver parameter to see what is coming out of the json string. JSON.parse() spits out the error in the console tab of the browser if it finds the issue with the passed string

JSON.parse('your string', (key, value) => {
  console.log(key); // log the current property name, the last is "".
  return value;     // return the unchanged property value.
});

MDN JSON.parse

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