I have json arrays as follows
payload.json
{"provision":"provision section 1",
"subsets": [{"item":"milk"},{"payments": [{"price": "170 usd"}]},
{"item":"sugar"},{"payments": [{"price": "70 usd"}]},
{"item":"tea"},{"payments": [{"price": "90 usd"}]}]}
Here is the code am using to get the json response
import json
import requests
r = requests.get('http://localhost/payload.json')
stat=r.status_code
head=r.headers['content-type']
encode=r.encoding
texting=r.text
result=r.json()
print(stat)
print(head)
print(texting)
print(result)
I can successfully get the results in json
My requirements:
How do I successfully loops to print out values for Provisions, item and price.
If i try something like print(result.provision), it will display error dict object has no attribute provision