Python JSON indexing -
i response method in zabbix here: https://www.zabbix.com/documentation/3.0/manual/api/reference/host/get
the json output looks if print whole response:
{ "property1": "value1", "property2": "value2", "property3": "value3" }
the problem is, cannot index correctly. tried response["property1"]
gave me error:
'zabbixapiobject' object has no attribute 'getitem'
also did try convert json that:
json.load(response)
the error gave me: 'nonetype' object not callable
what can problem? there way split response? need 1 attribute that.
edit:
request_command = { "jsonrpc": "2.0", "method": "hostgroup.get", "params": { "output": "extend", "search": { "name": "testgroup" } } } test_request = json.loads(requests.post("http://localhost/zabbix/api_jsonrpc.php", json.dumps(request_command)).text)
Comments
Post a Comment