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

154
Vistas
how to "destring" an object in an array

i have an array which looks like this:

[ 
"[-33.85812364015231, 151.19984484776273]", 
"[-33.85812364015231, 151.19984484776273]", 
"[-33.87137985320215, 151.19263084032974]"
]

how do i get the objects out of their strings. Parsing them into floats removed the second value in the object. Trying to replace( ' " ', " ") the speech marks doesn't work.

thanks

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

0

You have an array of JSON strings.

To get an array of arrays of numbers, use

const parsedArr = arr.map(JSON.parse);

and then parsedArray[someNum] will give you a coordinate array of numbers, like [-33.85812364015231, 151.19984484776273].

about 4 years ago · Juan Pablo Isaza Denunciar

0

this way :
without unnecessarily recreating a new array (as does the array.map() method )

const myArray = 
  [ "[-33.85812364015231, 151.19984484776273]"
  , "[-33.85812364015231, 151.19984484776273]" 
  , "[-33.87137985320215, 151.19263084032974]"
  ]
  
myArray.forEach((row,i,Arr) =>  Arr[i] = JSON.parse(row) )

console.log( myArray )
  

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