When I receive this type of data, the keys are common but the items vary. How can I extract and add this data to my list of categories?
{
"99": "Venues",
"100": "Party Supplies",
"101": "Entertainment",
"102": "Desserts",
"103": "Catering"
}
This is how I attempted to populate 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 what if the keys are not consistently named? For example:
{
"S99": "Venues",
"SDF100": "Party Supplies",
"CF101": "Entertainment",
"VF102": "Desserts",
"CFCV103": "Catering"
}
How can I add this data to my list without knowing the exact key format?