Hi,
How do I get the following information as a table in AMS?
I use the following code:
I would like to get the list with messages as a table, so I can query it, but I don't know how to do this?
Can someone help me out or point me in the right direction?
Thanks!
Eric
How do I get the following information as a table in AMS?
Code:
{ "checks": [ { "hostname": "example.com", "id": 85975, "lasterrortime": 1297446423, "lastresponsetime": 355, "lasttesttime": 1300977363, "name": "My check 1", "resolution": 1, "status": "up", "type": "http" }, { "hostname": "mydomain.com", "id": 161748, "lasterrortime": 1299194968, "lastresponsetime": 1141, "lasttesttime": 1300977268, "name": "My check 2", "resolution": 5, "status": "up", "type": "ping" }, { "hostname": "example.net", "id": 208655, "lasterrortime": 1300527997, "lastresponsetime": 800, "lasttesttime": 1300977337, "name": "My check 3", "resolution": 1, "status": "down", "type": "http" } ] }
I use the following code:
Code:
local ENV = [[]] local targetURL = "https://api.pingdom.com/api/2.0/checks/"; local Soap = luacom.CreateObject("WinHttp.WinHttpRequest.5.1"); if (Soap ~= nil) then Soap:Open("GET", targetURL, 0) Soap:SetRequestHeader("Authorization", "Basic "..cAuth) Soap:SetRequestHeader("Host", cHost) Soap:SetRequestHeader("App-Key", cAppKey) Soap:Send(); local result = Soap.ResponseText; if (Soap.Status == 200) then result = String.Replace(result, "\\/", "/", false); result = String.Replace(result, "\\r\\n", "\r\n", false); result = String.Replace(result, "\\n", "\n", false); json = require("dkjson"); local tblResult, pos, err = json.decode(result, 1, nil); if err then Dialog.Message("Error", err); else for k, v in pairs(tblResult) do Dialog.Message("Table Item", k.."="..v); end end else Dialog.Message("Error:", result, MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1); end Soap = nil; end
Can someone help me out or point me in the right direction?
Thanks!
Eric
Comment