2
I do not have much intimacy with JSON and I need to create a structure that contains a list of stores separated by categories, where each store item has some information (name, floor, phone etc.) I even thought of making a JSON for each category, but I’d like it to be all in one object so I can iterate.
I tried something like below but it’s not working out so well:
var ljs = {
"categ": "Loja de Departamentos",
"lojas": [
{
nome: "LOJA A",
piso: "1",
tel: "",
desc: "descrição da loja.",
imagem: "logo_a.jpg"
},
{
nome: "LOJA B",
piso: "1",
tel: "",
desc: "descrição da loja.",
imagem: "logo_b.jpg"
}
]
};
Besides "categ": "Loja de Departamentos"
will also have several other categories such as Confectioneries, Restaurants etc. I believe the key "lojas"
be even unnecessary.
How can I set up such a JSON, where it lists the categories and the list of stores for each one and then I can pull the data with a for
?
Are there stores that are in more than one category ? If this is the case it is easier to reverse and make an array of stores in which each store has an array of categories.
– Isac
No, only in 1 category.
– Sam