JSON neu strukturieren
Okay, Leute brauchen da draußen Hilfe. Ich lerne immer noch Javascript und seine Interaktionen JSON. Ich habe einen JSON wie diesen
[{
"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."
}];
Aber was ich brauche, ist ein JSON, das so aussieht
{
"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."
}
]
}
]
}]
}
}
Ich weiß, dass es ein bisschen hässlich ist, aber ich habe Probleme damit, herauszufinden, wie ich den neuen JSON-Code erstellen kann, während ich meinen aktuellen durchlaufe.
Jede Hilfe, die mich zum Laufen bringt, wäre großartig