Lazarus Pascal Requires Chilkat v11.0.0+
Lazarus Pascal
Example: Http.GetLastJsonData method
Demonstrates theGetLastJsonData method.
Chilkat Lazarus Pascal Downloads
program ChilkatDemo;
// Demonstrates using the Chilkat Pascal wrapper via the C bridge DLL.
// Builds as a console application under Lazarus (FPC) or Delphi.
{$IFDEF FPC}
{$MODE DELPHI}
{$ENDIF}
{$APPTYPE CONSOLE}
uses
{$IFDEF UNIX}
cthreads,
{$ENDIF}
SysUtils,
CkDllLoader,
Chilkat.Http,
Chilkat.HttpResponse,
Chilkat.JsonObject;
// ---------------------------------------------------------------------------
procedure RunDemo;
var
success: Boolean;
http: THttp;
resp: THttpResponse;
json: TJsonObject;
begin
success := False;
http := THttp.Create;
resp := THttpResponse.Create;
// Only allow TLS 1.2 or better.
http.SslProtocol := 'TLS 1.2 or higher';
success := http.HttpNoBody('GET','https://google.com/',resp);
if (success = False) then
begin
WriteLn(http.LastErrorText);
Exit;
end;
json := TJsonObject.Create;
json.EmitCompact := False;
http.GetLastJsonData(json);
WriteLn(json.Emit());
// Output as of Chilkat v11.1.0
// Additional information may be added as requested or needed in future versions of Chilkat.
// {
// "tls": {
// "params": {
// "sniHostname": "www.google.com",
// "allowConnectionOnlyIfServerChooses": "TLS 1.2 or higher"
// },
// "negotiatedTlsVersion": "TLS 1.3"
// }
// }
http.Free;
resp.Free;
json.Free;
end;
// ---------------------------------------------------------------------------
begin
try
RunDemo;
except
on E: Exception do
WriteLn('Unhandled exception: ', E.ClassName, ': ', E.Message);
end;
WriteLn;
{$IFDEF MSWINDOWS}
WriteLn('Press Enter to exit...');
ReadLn;
{$ENDIF}
end.