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

126
Vistas
Converting Array stored as a String to a List object in JavaString

I have the following list:

nested_list = [
  ["[63]"],
  ["[61]"],
  ["[7]"],
  ["[63]"],
  ["[80, 18]"],
  ["[80, 43, 18, 20]"]
]

Which is a mess I know, but this is the data that I have to deal with at the moment and I need it to be like this:

[63, 61, 7, 63, 80, 18, 80, 43, 18, 20]

So basically converting it into a list of numbers. Is this doable using as minimum loops as possible?

I have used flat() nested_list .flat(2) and ended up with the following result:

[ '[63]', '[61]', '[7]', '[63]', '[80, 18]', '[80, 43, 18, 20]' ]

Also tried reduce + concat following this but since it is a string, it is not working and I'm not sure where to go from here.

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

0

.flatMap() + JSON.parse() can do this quite easily

const nested_list = [
  ["[63]"],
  ["[61]"],
  ["[7]"],
  ["[63]"],
  ["[80, 18]"],
  ["[80, 43, 18, 20]"]
];

const result = nested_list.flatMap(JSON.parse);

console.log(result)

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