is there a way to store my JSON key data(id,name,price...) on each of my variable(id1-id3, id1-id3, price1-price3...)
here is my sample code
import json
from kivy.properties import StringProperty
f = open('sample.json')
data = json.load(f)
id1 = StringProperty(None)
id2 = StringProperty(None)
id3 = StringProperty(None)
name1 = StringProperty(None)
name2 = StringProperty(None)
name3 = StringProperty(None)
price1 = StringProperty(None)
price2 = StringProperty(None)
price3 = StringProperty(None)
quantity1 = StringProperty(None)
quantity2 = StringProperty(None)
quantity3 = StringProperty(None)
for i in data:
print(i)
and here is the JSON file
[
{
"id": "p01",
"name": "Name 1",
"price": 1,
"quantity": 1
},
{
"id": "p02",
"name": "Name 2",
"price": 2,
"quantity": 2
},
{
"id": "p03",
"name": "Name 3",
"price": 3,
"quantity": 3
}
]
i'm planning to use bigger data. but for simplicity's sake, i just use 3 items as an example