Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

140
Views
Necesito poner este objeto en una matriz, ¿cómo?

Necesito convertir lo siguiente en el formato EXACTO que se muestra a continuación con javascript, ¿podría sugerir cómo lograr esto?

de: {"healthy":true,"unhealthy_reasons":[]}
a: [{"healthy":true,"unhealthy_reasons":[]}]

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Si eso es todo lo que necesita hacer, puede envolver corchetes de matriz alrededor de la variable que contiene el objeto:

 let initialObject = {"healthy":true,"unhealthy_reasons":[]}; let arrayedObject = [initialObject];

Pero me pregunto si hay más en esto. Si esto es realmente parte de una tarea más complicada, solo agréguelo a su pregunta y obtendrá una respuesta más completa.

about 4 years ago · Juan Pablo Isaza Report

0

Utilice JSON.parse() y JSON.stringify()

 let data = '{"healthy":true,"unhealthy_reasons":[]}'; let parsed = JSON.parse(data); //TO get an array console.log([parsed]) //TO get a string console.log(JSON.stringify([parsed]))

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!