hi i need loop for show list produit
this structure the json
Code:
[
{
"list": [
{
"listProduit": [
{
"title": "Four for All Chicken",
"descriptionProduit": "Chicken strips, boneless, potatoe wedges, onion rings",
"price": "99,00DHS",
"cat": "Appetizers"
}
.....
],
"nameCategory": "Appetizers",
"imgCategory": "http://assets.hellofood.ma/dynamic/images/menucategories/7533_menu.jpg",
"res": "Giovanni House"
},
{
"listProduit": [
{
"title": "Salade Caprese",
"descriptionProduit": "Mesclun de salade, tomates fraîches, mozzarella, basilic",
"price": "49,00DHS",
"cat": "Salades"
}...
],
"nameCategory": "Salades",
"imgCategory": "http://assets.hellofood.ma/dynamic/images/menucategories/7532_menu.jpg",
"res": "Giovanni House"
},
.....
],
"img": "http://assets.hellofood.ma/dynamic/images/vendors/m1yz_sqp.JPG?v=20160223180539",
"name": "Giovanni House",
"description": "Burgers Cuisine italienne Pizza Salades Sandwichs ",
"livreDans": "30min",
"fraisLaifraison": null,
"valeurMin": "89,00DHS",
"linkcat": "https://www.hellofood.ma//restaurant/m1yz/giovanni-house"
}
.....
]
i try this but i have in erreur
Code:
for produit in j[self.restaurant]['list']:
for pr in j[self.category]['listProduit']:
listitem = xbmcgui.ListItem(label=pr['title'], iconImage='iconwili.png')
listitem.setProperty("MyDescription",pr['descriptionProduit'])
listitem.setProperty("MyPrice",pr['price'])
listitem.setProperty("MyImage", j['list'][self.category]['imgCategory'])
self.getControl( PRODUIT_LIST ).addItem( listitem )
self.setFocus( self.getControl( PRODUIT_LIST ) )
socket.setdefaulttimeout(None)
17:00:09 T:3572 ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <type 'exceptions.KeyError'>
Error Contents: ('listProduit',)
Traceback (most recent call last):
File "C:\Users\abdelfattah\AppData\Roaming\Kodi\addons\script.program.boxty.HelloFood\resources\lib\Produit.py", line 84, in onInit
self.setup_all()
File "C:\Users\abdelfattah\AppData\Roaming\Kodi\addons\script.program.boxty.HelloFood\resources\lib\Produit.py", line 94, in setup_all
for pr in j[self.category]['listProduit']:
KeyError: ('listProduit',)
-->End of Python script error report<--