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

131
Views
¿Extraer el valor dentro de un objeto JSON multianidado con un "número" como nombre clave?

Estoy tratando de obtener el título de la primera canción en el objeto JSON a continuación, pero tengo que pasar por un número como nombre clave.

Normalmente, podemos hacer esto: title = top100.content.rank.title pero no funciona con title = top100.content.1.title como el objeto a continuación.

Mi solución actual es: title = Object.values(Object.values(top10.data)[1])[0].title que es muy largo y feo. Si tienes una mejor manera, por favor ayúdame.

 top100 = { "info": { "category": "Billboard", "chart": "HOT 100", "date": "2021-09-11", "source": "Billboard-API" }, "content": { "1": { "rank": "1", "title": "Butter", "artist": "BTS", "weeks at no.1": "10", "last week": "7", "peak position": "1", "weeks on chart": "15", "detail": "up" }, "2": { "rank": "2", "title": "Stay", "artist": "The Kid LAROI & Justin Bieber", "last week": "1", "peak position": "1", "weeks on chart": "8", "detail": "down" }, ... } }
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

puede usar la sintaxis obj[clave]

 top100['content'][1]['title']
about 4 years ago · Juan Pablo Isaza Report

0

puedes acceder al título de la primera canción de esta manera:

 top100.content["1"].title
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!