Delphi DLL
Delphi DLL
Get JSON Details from the Last REST Operation
See more REST Examples
Demonstrates Rest.GetLastJsonData, which copies operation-specific diagnostic or result information from the most recently completed method into a JsonObject. Many methods produce no JSON, in which case the object is empty.
Tip: Code to parse the returned JSON can be generated with Chilkat's online tool at https://tools.chilkat.io/jsonParse.
Background. Some Chilkat operations expose additional structured information as JSON. GetLastJsonData provides access to that information after an operation completes.
Chilkat Delphi DLL Downloads
var
success: Boolean;
rest: HCkRest;
bTls: Boolean;
bAutoReconnect: Boolean;
json: HCkJsonObject;
jsonStr: PWideChar;
begin
success := False;
rest := CkRest_Create();
bTls := True;
bAutoReconnect := True;
success := CkRest_Connect(rest,'example.com',443,bTls,bAutoReconnect);
if (success = False) then
begin
Memo1.Lines.Add(CkRest__lastErrorText(rest));
Exit;
end;
// Copy operation-specific diagnostic or result information from the most recent method (here the
// Connect call) into a JsonObject. Many methods produce no JSON, in which case the object is empty.
json := CkJsonObject_Create();
CkRest_GetLastJsonData(rest,json);
CkJsonObject_putEmitCompact(json,False);
jsonStr := CkJsonObject__emit(json);
Memo1.Lines.Add(jsonStr);
// JSON parsing code for this result can be generated at Chilkat's online tool:
// https://tools.chilkat.io/jsonParse
CkRest_Dispose(rest);
CkJsonObject_Dispose(json);