Parsing nested json in python

Question:

I’m trying to parse the following json to get the Item (Item1, Item2 …) and URL fields out of the payload. I’m able to parse out the Item1, Item2 no problem with something like this but I’m at a loss of how to get the URL out of it as well

resp = requests.get(url)
data = json.loads(resp.text)
items = data["items"]
for item in items:
    print(item)

I’ve tried adding something like this just to get the subscriptions but receive KeyError: 0

subscriptions = data["items"][0]

Payload:

{
  "items": {
    "Item1": {
      "subscriptions": [
        {
          "url": "https://someurl.com",
          "name": "Customer1",
          "categories": [
            "Appointment"
          ]
        }
      ]
    },
    "Item2": {
      "subscriptions": [
        {
          "name": "Customer2",
          "url": "https://someotherurl.com",
          "authPass": "",
          "authUser": "",
          "categories": [
            "Appointment"
          ]
        }
      ]
    }
  }
}
Asked By: tweeks200

||

Answers:

Just keep digging

Item1_url= data["items"]["Item1"]["subscriptions"][0]['url']
Answered By: SuperStew
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.