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

213
Vistas
Is there a way to convert a string to a proper array, not an array of strings or an array of characters?

I have this string “[{value: 1400, value1: 50, value2: 48}, {value: 1500, value1: 20, value2: 88}]" and I need to convert into a list [{value: 1400, value1: 50, value2: 48}, {value: 1500, value1: 20, value2: 88}] in JavaScript, is there a way to do that??

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

you can use the eval() function. (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval#never_use_eval!)

Please be aware, that eval() shouldnt be used generally as you can read in the article above.

Example:

const array = eval('[{value: 1400, value1: 50, value2: 48}, {value: 1500, value1: 20, value2: 88}]');

Edit: I would suggest to modify you string to fit the JSON-Standard. To achieve this, you would have to put the keys of your objects in quotation marks like this:

let yourString =  '[{"value": 1400, "value1": 50, "value2": 48}, {"value": 1500, "value1": 20, "value2": 88}]';
const array = JSON.parse(`${yourString}`);

This will work ^^

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