You are not logged in.
Pages: 1
Hello,
Where I can find any examples or documentation for serialization on Delphi for records on Mac, Linux and Android?
This is possible?
I need analogs of RecordLoadJSON and RecordSaveJSON on Windows platform
Last edited by EgorovAlex (2018-04-07 19:59:32)
Offline
What do you mean by reserialization?
All documentation is at https://synopse.info/files/html/Synopse … 01.18.html
Explanation for record saving/loading is at 10.1.3
Offline
This was typing error. Fixed.
I need this functions for cross-platform delphi compiler
Last edited by EgorovAlex (2018-04-07 16:15:34)
Offline
They don't exist yet in SynCrossPlatform units.
Since for our internal purpose, which is SOA clients, we generate the code using Mustache templates to make fast serialization/deserialization.
Offline
Can you provide any short and simle example to do that?
Read about Mustache usage but did not understand how to use it for this purpose
Offline
Documentation is
https://synopse.info/files/html/Synopse … DE_TITL_86
And sample is
https://github.com/synopse/mORMot/tree/ … %20Clients
Offline
This is my current realization for client or this can be faster?:
type
TRec = record
type
TSQLRec = class(TPersistent)
private
fName: string;
fDate: TDateTime;
fInt : UInt16;
published
property Name: string read fName write fName;
property Date: TDateTime read fDate write fDate;
property Int : UInt16 read fInt write fInt;
end;
public
Name: string;
Date: TDateTime;
Int : UInt16;
procedure FromJSON(const AJSON: string);
function ToJSON: string;
end;
{ TRec }
procedure TRec.FromJSON(const AJSON: string);
var
lRec: TSQLRec;
begin
lRec := TSQLRec.Create;
try
if JSONToObject(lRec, AJSON) then begin
Name := lRec.Name;
Date := lRec.Date;
Int := lRec.Int;
end;
finally
lRec.Free;
end;
end;
function TRec.ToJSON: string;
var
lRec: TSQLRec;
begin
lRec := TSQLRec.Create;
try
lRec.Name := Name;
lRec.Date := Date;
lRec.Int := Int;
Result := ObjectToJSON(lRec);
finally
lRec.Free;
end;
end;
Offline
Pages: 1