I have an JSON-RPC of the form: [{"priority": "0", "actionsList": [{"type": "OUTPUT", "port": 2}], "match": {"wildcards": 3145968, "nw_dst": "10.0.0.2", "dl_src": "00:00:00:00:01:01", "dl_dst": "00:00:00:00:04:02", "dl_vlan": 65535, "nw_src": "10.0.0.1", "in_port": 3}}, {"priority": "0", "actionsList": [{"type": "OUTPUT", "port": 3}], "match": {"wildcards": 3145968, "nw_dst": "10.0.0.1", "dl_src": "00:00:00:00:04:02", "dl_dst": "00:00:00:00:01:01", "dl_vlan": 65535, "nw_src": "10.0.0.2", "in_port": 2}}]
I parse using the following code:
flowTableJSON = do_func(gopts, opts, args)
print type(flowTableJSON)
print flowTableJSON
for flow in flowTableJSON:
print 'in for loop'
print flow['match']['dl_src']
print flow['match']['dl_dst']
Printing the variable flowTableJSON outputs the example JSON above, while the type of flowTableJSON is Nonetype. Is it possible for a variable to store a value and be of type Nonetype?
Essentially, I am trying to access the value stored in dl_dst in each of the elements of the JSON; how would I do that?
I'm willing to bet that the problem is that do_func
just prints out the JSON and doesn't return anything. So, flowTableJSON
is None
, so its type is NoneType
, and that's printing after the JSON.
I know you said the NoneType
was printing before the JSON, but you also said it was Nonetype
, and I find that unlikely, so my guess is you're just being not paying enough attention.