I am calling an API which returns a complicated json:
{"results": [{"attrs": {"name": "par.abd","state": 1.0},
"joins": {},
"meta": {},
"name": "par.abd",
"type": Host"
},
{"attrs": {"name": "bbc.abd","state": 1.0},
"joins": {},
"meta": {},
"name": "bbc.abd",
"type": "Host"
}]}
How do I extract just the name and state for attrs?
Use the json module:
Note that I had to add a missing
"near the end of your string - I hope it only disappeared when you copied it here.