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

143
Views
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 answers
Answer question

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 Report

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 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!