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

96
Vistas
Make JSON.parse work for array of objects with quotation mark

I am trying to store an array of object as string and restore it later. However, some elements in the objects are string and they may have ' or ". This causes an issue when I try to convert back and forth this array of objects to string with JSON.parse. Is there an standard way to resolve this issue?

 vars = [{'date': '04-29', 'x': 'this "x" ', 'y': '<p><img src="data:image/jpeg;base64,/9j/4AADEQA/ANmAA9KdX/txX0/2Q=="></p>'}]
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

try this

vars=JSON.parse(JSON.stringify(vars));

result

[{"date":"04-29","x":"this \"x\" ","y":"<p><img src=\"data:image/jpeg;base64,/9j/4AADEQA/ANmAA9KdX/txX0/2Q==\"></p>"}]

or this ( I don't know what you want to reach)

vars = JSON.parse(JSON.stringify(vars).replaceAll("\\\"","'"));

result

[{"date":"04-29","x":"this 'x' ","y":"<p><img src='data:image/jpeg;base64,/9j/4AADEQA/ANmAA9KdX/txX0/2Q=='></p>"}]
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