python: can json accept bytes string or need conversion?

Viewed 20

I receive a string in a following form (result of bridge -j fdb show command):

b'[{"mac":"00:00:00:00:11:22","ifname":"eth0","flags":[],"master":"br0","state":""},{"mac":"00:aa:bb:00:00:11","ifname":"eth1","vlan":1,"flags":[],"master":"br1","state":""}]\n'

Is this a valid json and can be fed to json.loads() or requires some conversion?

I did try to load it with json.loads() and it return a list of dictionaries:

[{'mac': '00:00:00:00:11:22', 'ifname': 'eth0', 'flags': [], 'master': 'br0', 'state': ''}, {'mac': '00:aa:bb:00:00:11', 'ifname': 'eth1', 'vlan': 1, 'flags': [], 'master': 'br1', 'state': ''}]

which I can iterate and search.

But may be I'm missing something? I'm newbie in python :)

0 Answers
Related