Closed maxkleiner closed 1 year ago
procedure GetJSONData;
var XMLhttp: OleVariant; // As Object Automation
ajt: TJson; JObj: TJsonObject2; JArray: TJsonArray2;
response,statuscode: string; cnt: integer; //md: TDims;
begin
XMLhttp:= CreateOleObject('msxml2.xmlhttp')
XMLhttp.Open('GET', WEBURL, False) //False is async
//XMLhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
XMLhttp.setRequestHeader('Content-Type', 'application/json; charset=utf-8');
XMLhttp.Send();
response:= XMLhttp.responseText; //assign the data
statuscode:= XMLhttp.status;
//writeln(statuscode +CRLF+ response)
ajt:= TJson.create();
try
ajt.parse(response);
except
writeln( 'Exception:
for cnt:= 0 to jarray.count-1 do
writeln(itoa(cnt)+' '+Jarray.items[cnt].asObject.values['title'].asString);
ajt.Free;
end;
Microsoft Windows HTTP Services (WinHTTP) provides developers with an HTTP client application programming interface (API) to send requests through the HTTP protocol to other HTTP servers.