Skip to content

Instantly share code, notes, and snippets.

@SimaWB
Last active October 18, 2019 11:29
Show Gist options
  • Save SimaWB/2770533969dabbebe2ff76b02a42cc7d to your computer and use it in GitHub Desktop.
Save SimaWB/2770533969dabbebe2ff76b02a42cc7d to your computer and use it in GitHub Desktop.
Class to JSON example
unit ClassToJSON;
interface
uses
REST.JSON;
type
TLogin = class
private
FUserCode, FPassword: string;
public
property UserCode: string read FUserCode write FUserCode;
property Password: string read FPassword write FPassword;
class function ToJSON(U, P: string): string;
end;
implementation
{ TLogin }
class function TLogin.ToJSON(U, P: string): string;
var
aLogin: TLogin;
begin
aLogin := TLogin.Create;
try
aLogin.UserCode := U;
aLogin.Password := P;
Result := TJson.ObjectToJsonString(aLogin);
finally
aLogin.Free;
end;
end;
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment