I'm trying to figure out how to parse a nested object in JSON using JavaScript. Here's the code I have so far:
var myRequest = new Request('test.json');
fetch(myRequest)
.then(function(response) { return response.json(); })
.then(function(data) {
console.log(data. ??????????);
});
Here is the JSON file I am working with:
{
"products": {
"29033669": {
"anzahl": "11x",
"img": "https://static.openfoodfacts.org/images/products/29033669/front_de.3.400.jpg",
"name": "Zitronenteegetränk"
},
"4001686386613": {
"anzahl": "1x",
"img": "https://static.openfoodfacts.org/images/products/400/168/638/6613/front_de.17.400.jpg",
"name": "Haribo Saft Goldbären"
},
"4008400207322": {
"anzahl": "5x",
"img": "https://static.openfoodfacts.org/images/products/400/840/020/7322/front_de.6.400.jpg",
"name": "Kinder Schokolade"
},
"40518152": {
"anzahl": "4x",
"img": "https://static.openfoodfacts.org/images/products/40518152/front_en.3.400.jpg",
"name": "Karamalz classic"
},
"676478232": {
"anzahl": "1x",
"img": "https://cdn4.iconfinder.com/data/icons/aami-web-internet/64/aami18-38-512.png",
"name": "Bananen"
},
"7613035499768": {
"anzahl": "4x",
"img": "https://static.openfoodfacts.org/images/products/761/303/549/9768/front_de.6.400.jpg",
"name": "Choclait Chips Classic"
}
}
}
Any help on this would be greatly appreciated! Levi