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

155
Visualizações
How to get data without knowing key of json in react native

In response i get this king of data, here in data object there is various items but there key are kind of common so how can i get that data and add in my categories list.

{
   "99": "Venues",
   "100": "Party Supplies",
   "101": "Entertainment",
   "102": "Desserts",
   "103": "Catering"
}

here, how i tried to set the data in my list.

const dataItem = data.data;
const newList = [];
newList.push({item: dataItem[99]});
newList.push({item: dataItem[100]});
newList.push({item: dataItem[101]});
setList(newList);

but when i don't have the proper name of key then how can i add it to my list? ex. sometimes i get the key like...

{
    "S99": "Venues",
    "SDF100": "Party Supplies",
    "CF101": "Entertainment",
    "VF102": "Desserts",
    "CFCV103": "Catering"
}

So, how can i set the data in list without knowing the item key.

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

0

You can get key and value both by using following code

for (var key in data.data) {
   console.log(key); // This will return a key, in your case it will be S99, SDF100...
   console.log(JSON_Obj[key]); // This will return value for that key.
   newList.push({item: data.data[key]});
}

from this you can add values in your list

about 4 years ago · Juan Pablo Isaza Relatório

0

let data = {
 "S99": "Venues",
 "SDF100": "Party Supplies",
 "CF101": "Entertainment",
 "VF102": "Desserts",
 "CFCV103": "Catering"
}

const list = Object.values(data);
console.log(list);

// print (5) ['Venues', 'Party Supplies', 'Entertainment', 'Desserts', 'Catering']

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