cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
4012
Views
6
Helpful
3
Replies

Python dictionary to list

Fabian11
Level 4
Level 4

Hi everyone,

this is more basic python, but I stuck with this problem:

When I get the data of an ssid, the response is always a dictionary ('name' : 'something, ' number' : 22...) from Meraki which is fine.

But if I want to update the ssid, it has to be done in a form of name = 'something, number = '22'...

How do you convert this?

I don't want to hard code the config, I just want to change one of the values.

Thanks and best

Fabian

1 Accepted Solution

Accepted Solutions

psteinbe
Level 3
Level 3

@Philip D'AthIs correct and this is probably the easiest way to do it.

A simple for loop through networks and ssids will get you through the data you need to change. Something like the below.

nets = meraki.organizations.getOrganizationNetworks(organizationId)

for net in nets:

ssids = meraki.wireless.getNetworkWirelessSsids(net['id'])

for ssid in ssids:

if ssid['name'] == "something":

ssid.update({'psk' : 'newpassword'}) # use the update() function when working with dictionaries. #

ssidChange = meraki.wireless.updateNetworkWirelessSsid(net['id'], **ssid) # the double * (**) will unpack the dictionary and allow you to post the full dictionary as the new variables. Be careful with this as you may get a return value that won't post.

View solution in original post

3 Replies 3

Philip D'Ath
Meraki Community All-Star
Meraki Community All-Star

Iterate through the dictionary and test each row for the value you are looking for (such as SSID) and then change that one row.

psteinbe
Level 3
Level 3

@Philip D'AthIs correct and this is probably the easiest way to do it.

A simple for loop through networks and ssids will get you through the data you need to change. Something like the below.

nets = meraki.organizations.getOrganizationNetworks(organizationId)

for net in nets:

ssids = meraki.wireless.getNetworkWirelessSsids(net['id'])

for ssid in ssids:

if ssid['name'] == "something":

ssid.update({'psk' : 'newpassword'}) # use the update() function when working with dictionaries. #

ssidChange = meraki.wireless.updateNetworkWirelessSsid(net['id'], **ssid) # the double * (**) will unpack the dictionary and allow you to post the full dictionary as the new variables. Be careful with this as you may get a return value that won't post.

The **ssid and ssid.update did the trick, this is awsome, thank you guys 🙂