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

139
Visualizações
How to find JSON data based on what else is in the JSON object when duplicates exist?

I'm currently working on some data chart implementation on a website, and I have a JSON with some data, notably some ID numbers, some dates, and some datapoints. Because I have multiple dates under the same ID, I'm looking for a way to do what is essentially "Find the JSON object that has this ID and Month, then get the datapoint numbers from that object". Any help on how I would accomplish this? Preferably without iteration, if possible, as the file is extremely large. I'll include an example of what the JSON looks like:

[{
"ID" : "32",
"month" : "6",
"value" : "438"
},
{
"ID" : "32",
"month" : "5",
"value" : "223"
}

It should also be noted that the ID's aren't grouped together like this in the actual json, this is just an example. Also changing the json contents is not an option.

Any help is greatly appreciated, thank you!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

In JS you could use array.find.

Something like res = myArray.find(item => item["ID"] === "32" && item["month"] === "5").

Then res is the object your searching for.


If you want to accomplish lookups without any iteration you'd need to generate a data structure with unique keys, ie. make a new object with keys something like id-month.

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