You are not logged in.
Pages: 1
Hi I have problem with ObjectToJSON using SynCrossPlatformJSON.pas
TTestJson = class(TObject)
private
FAge: Integer;
FFirstName: string;
FLastName: string;
procedure SetAge(const Value: Integer);
procedure SetFirstName(const Value: string);
procedure SetLastName(const Value: string);
public
property Age: Integer read FAge write SetAge;
property FirstName: string read FFirstName write SetFirstName;
property LastName: string read FLastName write SetLastName;
end;
{...}
var
S1: TTestJson;
begin
S1 := TTestJson.Create;
try
S1.Age := 30;
S1.FirstName := 'Peter';
S1.LastName := 'My Last Name';
Memo1.Text := ObjectToJSON(S1); // <-- return 'null'
finally
S1.Free;
end;
end;
How to correctly use ObjectToJSON using SynCrossPlatformJSON.pas
Thanks for help.
Last edited by mitring (2015-10-22 05:40:11)
Offline
Thanks for reply
Inherited by TPersistent is one and two propery not public but published
TTestJson = class(TPersistent)
private
FAge: Integer;
FFirstName: string;
FLastName: string;
procedure SetAge(const Value: Integer);
procedure SetFirstName(const Value: string);
procedure SetLastName(const Value: string);
published
property Age: Integer read FAge write SetAge;
property FirstName: string read FFirstName write SetFirstName;
property LastName: string read FLastName write SetLastName;
end;
Once again thanks for help and for mORMot
Offline
Pages: 1