I have my JSON file:
[
{
"order_":{
"id":"B2B78502",
"status_order_id":5,
"status_order_name":"Sent",
"customer_id":256,
"order_products":[
{
"order_product":{
"id":83630,
"order_id":79288,
"product_id":13519,
"quantity":"1.0",
"price":"72.44",
"addressbook_":{
"name":"user user",
"address":"adress",
"city":"THIENNES",
"country":"FR",
"postal_code":"59189",
"phone":"000000000"
},
"product_name":"product",
"product_code":"20159"
}
}
],
"customer_email":"[email protected]",
"customer_company":"SARL"
}
}
]
I want to insert data into a MySQL table, but I can not access all the values
here is my code:
json_obj = r.json()
for ord in json_obj:
print("id:", ord["order"]["id"])
print("order_produvt_id:", ord["order"]["order_products"]"order_product"]["id"])
print('---')
I want to access all the data I want to access all the data but I get this error :
id: B2B78588
print("order_product_id:", ord["order"]["order_products"]["order_product"]["id"])
TypeError: list indices must be integers or slices, not str