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

150
Vistas
Why JSON.parse fails with this array-like string

I tried to JSON parse this

  let string = `["\"test1, "\"test2"]`;
  let array = JSON.parse(string);
  console.log(array[0]);

It's fairly simple enough but I don't understand what's error message is supposed to tell

  Uncaught SyntaxError: Unexpected token t in JSON at position 3
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

you are using template string to create a string. it doesnt need a escape character for double quotes ". type this:

let string = `["test1", "test2"]`;
let array = JSON.parse(string);
console.log(array[0])

you need a escape character for " only when you are using normal string. like this:

let string = "[\"test1\", \"test2\"]";
let array = JSON.parse(string);
console.log(array[0])

im not good at english.hope useful

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