I am trying to create a model for my categories object below:
{
"categories": [
{
"sandwiches": [
{
"name": "breadedChickenFlatbread",
"description": "A good sandwich",
"img": "./sandwich.jpg",
"price": "$8.99"
}
]
},
{
"pizzas": [
{
"name": "PizzaPie",
"price": "5milliondollars",
"img": "",
"description": ""
}
]
}
]
}
I'm not sure how to create the model portion for "categories" since the data items can change. For example, instead of "sandwiches" and "pizzas", the api could return "burgers" and "sides".
Here is what I have:
export class Menu {
categories: Array<Category>;
}
class Category {
// ?
}
// Details will always be the same
class Details {
name: string;
description: string;
img: string;
price: string;
}
How can I map the category names in my object, to my model? Or should the response object be changed