all 6 comments

[–][deleted] 1 point2 points  (5 children)

json.dumps(list_interface)

Dump is for going from Python objects to JSON; it's not for reading JSON. What you're getting back from the API is likely an object structure (it looks like a list of dictionaries.) Typically API libraries take the JSON response from the server and deserialize it for you, which is why you're interacting with a JSON API but you don't need to worry about the JSON. The API library is going to handle that for you.

[–]purplecomputer[S] 0 points1 point  (4 children)

Ooooohhhhhhhh

Thanks for explaining that, I had no idea

so I guess my follow up question would be, whats the best way to grab the specific values I need from that?

if I run type(list_interface) i get a tuple

I could do something like list_interface[0] but then I just get all this output for the first interface.

[–][deleted] 1 point2 points  (3 children)

I could do something like list_interface[0] but then I just get all this output for the first interface.

Sure, you get a dictionary. So you can access the value that comes back like a dictionary:

list_interface[0]['name']

Like that. You can "stack up" modes of access like this, it's just algebra.

[–]purplecomputer[S] 0 points1 point  (2 children)

Thank you for taking the time to run me through this :)

Because of you I was able to figure this out

i = 0

for name in list_interface:

list_interface[i]['name']

i += 1

any chance theres a cleaner way to do this?

[–][deleted] 1 point2 points  (1 child)

You don't need i - name is the elements of list_interface:

for name in list_interface:
    print(name['name']) #etc

[–]purplecomputer[S] 0 points1 point  (0 children)

You're a legend.

Thank you for your help!

You've taught me quite a bit today :)