Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

135
Visualizações
Extract value inside a multi-nested JSON Object with a "number" as a key name?

I'm trying to get the title of the first song in the JSON Object below but I have to go through a number as a key name.

Normally, we can do like this: title = top100.content.rank.title but it doesn't work with title = top100.content.1.title like the Object below.

My current solution is: title = Object.values(Object.values(top10.data)[1])[0].title which is very long and ugly. If you have a better way, please help me.

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 Respostas
Responde à pergunta

0

you can use the obj[key] syntax

top100['content'][1]['title']
about 4 years ago · Juan Pablo Isaza Relatório

0

you can access title of the first song in this way:

top100.content["1"].title
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda