Here Some script to parsing json file using Python :
data_barang.josn
{
"data":{
"row" : [
{
"id":"10001",
"nama_barang":"Air Mineral",
"stok":"7",
"satuan":"Botol",
"harga":"5000"
},
{
"id":"10002",
"nama_barang":"Minyak Goreng",
"stok":"10",
"satuan":"Pcs",
"harga":"20000"
}
]
}
}
tania.py
import json
json = json.loads(open('data_barang.json').read())
value = json['data']['row']
for i in range (len (value)):
print("=================================")
print("Nomor : ",i+1)
print("Id Barang : ",value[i]['id'])
print("Nama Barang : ",value[i]['nama_barang'])
print("Stok : ",value[i]['stok'])
print("Satuan : ",value[i]['satuan'])
print("Harga : ",value[i]['harga'])
print("=================================")
Top comments (0)