0

I have the following json output assigned to a variable called "mydict":

{
  "data": {
    "endpoints": {
      "edges": [
        {
          "node": {
            "name": "test1.net",
            "ipAddress": "1.2.3.4"
          }
        },
        {
          "node": {
            "name": "test2.net",
            "ipAddress": "4.3.2.1"
          }
        },
        {
          "node": {
            "name": "test3.net",
            "ipAddress": "0.0.0.0"
          }
        }
      ]
    }
  }
}

I'm able to print out a single "name" value with:

print("Dictionary contains: ",mydict['data']['endpoints']['edges'][1]['node']['name'])

But with how the data is nested, I'm not sure how to iterate through each "name" to get a print of only those values. Any recommendations? Thank you!

1 Answer 1

2
for edge in mydict['data']['endpoints']['edges']:
    print(edge['node']['name'])
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.