Перестройка JSON
Ок, ребята, нужна помощь. Я все еще изучаю Javascript и JSON его взаимодействия. У меня есть JSON, как это
[{
"categories":"Food",
"subcategories":"Shares",
"pid":"111",
"title":"Smoked Salmon Dip",
"description":"Rich and savory salmon dip, whipped with fresh dill accompanied with croustades"
},
{
"categories":"Food",
"subcategories":"Shares",
"pid":"112",
"title":"Sweet Goat Cheese Flatbread",
"description":"Delicate grilled Naan flatbread coated with delish tomato jam and topped with melted goat cheese, roasted garlic, fennel, onion, pear, shiitake mushroom and arugula."
},
{
"categories":"Food",
"subcategories":"Snacks",
"pid":"100",
"title":"Beer Chili",
"description":"Hot & satisfying short rib chili with black beans, smoked jalapenos, and fresh corn. Topped with aged cheddar cheese and sour cream."
}];
Но мне нужен JSON, который выглядит следующим образом
{
"menu":{
"categories":[
{
"name":"Food",
"subcategories":[
{
"name":"Shares",
"items":[
{
"pid":"111",
"title":"Smoked Salmon Dip",
"description":"Rich and savory salmon dip, whipped with fresh dill accompanied with croustades"
},
{
"pid":"112",
"title":"Sweet Goat Cheese Flatbread",
"description":"Delicate grilled Naan flatbread coated with delish tomato jam and topped with melted goat cheese, roasted garlic, fennel, onion, pear, shiitake mushroom and arugula."
}
]
},
{
"name":"Snacks",
"items":[
{
"pid":"100",
"title":"Beer Chili",
"description":"Hot & satisfying short rib chili with black beans, smoked jalapenos, and fresh corn. Topped with aged cheddar cheese and sour cream."
}
]
}
]
}]
}
}
Я знаю, что это немного некрасиво, но мне сложно понять, как создать новый JSON, когда я перебираю свой текущий.
Любая помощь, которая поможет мне справиться с этим, будет потрясающей