You are not logged in.
Pages: 1
I'm not sure if what I wrote is correct. DataRec can't get the data.
type
TDataRec = packed record
userId: integer;
id: integer;
title: RawUtf8;
completed: boolean;
end;
PDataRec = ^TDataRec;
TDataRecArr = array of TDataRec;
procedure TestJsonClient;
implementation
procedure TestJsonClient;
var
JsonClient: TJsonClient;
DataRecArr: TDataRecArr;
DataRec: TDataRec;
begin
FillChar(DataRecArr, SizeOf(DataRecArr), 0);
JsonClient := TJsonClient.Create('https://jsonplaceholder.typicode.com');
JsonClient.Request('GET', 'todos/%', [1], [], [], DataRec, TypeInfo(TDataRec), nil);
end;
The following is the returned data.
https://jsonplaceholder.typicode.com/todos/1
{
"userId": 1,
"id": 1,
"title": "delectus aut autem",
"completed": false
}
Offline
On which compiler?
lazarus 3.0
FPC 3.2.2
WIN64
Offline
There is not enough RTTI on FPC 3.2.2 to define the record fields.
You need to describe your record with a text definition in your code.
This is what is done for example with our OpenAPI generator.
It's done! Thank you.
Offline
Pages: 1