Last active
October 18, 2019 11:29
-
-
Save SimaWB/2770533969dabbebe2ff76b02a42cc7d to your computer and use it in GitHub Desktop.
Class to JSON example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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