You are not logged in.
Pages: 1
Hello,
I am using Lazarus 2.0.1, fpc 3.2.0, mORMot commit 1.18.5014. Platform is Raspberry Pi.
I have a pretty simple json, but I cannot handle it for a reason I don't know. I will try to keep my code examples minimum.
// json I am dealing is:
{
"controller": true,
"apiVersion": 4,
"clock": 1550842219493,
"databaseReady": true
}
type
TController = packed record
controller: Boolean;
apiVersion: Integer;
clock: UInt64;
databaseReady: Boolean;
end;
function IsControllerUp(): Boolean;
var
Controller: TController;
Json: string;
J: RawUTF8;
begin
Result := CallURL('controller', Json); // do rest request and retrieve result string
if Result then
begin
J := RawUTF8(Json);
if RecordLoadJSON(Controller, J, TypeInfo(TController)) then
begin
Exit(Controller.controller);
end
else
begin
Exit(False);
end;
end;
end;
IsControllerUp() function above returns false and while debugging I see that RecordLoadJSON() return false and record is not modified at all.
I did try several things like using a RawUTF8 variable ("J" in above code for that matter) instead of typecasting, double checked my record definition. I could not see a problem.
Any help is appreciated.
Thanks & regards,
Ertan
Offline
Thanks. That did solve my problem.
Is there a version of fpc which has record RTTI?
Offline
Pages: 1