I'm having trouble trying to get a list of values from a specific key inside an json array using python. Using the JSON example below, I am trying to create a list which consists only the values of the price key. Original JSON:
{
"data":
[
{
"id": 72292977,
"name": "Smart Cook inox 316 410ml EDA0309",
"price": 199000
},
{
"id": 73124602, "sku": "7494611465205",
"name": "Lock&Lock Vacuum Bottle LHC6180SLV (800ML)",
"price": 293000
}
]
"paging":
{
"total": 1876,
"per_page": 48,
"current_page": 1
}
}
Expected:
["199000 ", "293000"]
Below is the code of my approach:
import json
try:
with open("data.json", 'r') as f:
contents = json.load(f)
except Exception as e:
print(e)
How can I get the price value after loading json?