unit Unit2;
interface
uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls,
DBXJSON, DBXJSONReflect;
type
TPerson = class(TObject)
public
Name: String;
Password: String;
Age: Integer;
end;
TForm2 = class(TForm)
Memo1: TMemo;
procedure FormCreate(Sender: TObject);
private
function ObjectToJSON(AData: TObject): TJSONValue;
function JSONToObject(AJSONValue: TJSONValue): TObject;
public
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
function TForm2.JSONToObject(AJSONValue: TJSONValue): TObject;
var
lUnMarshal: TJSONUnMarshal;
begin
lUnMarshal := TJSONUnMarshal.Create();
try
Result := lUnMarshal.Unmarshal(AJSONValue);
finally
FreeAndNil(lUnMarshal);
end;
end
XE5 JSON与Delphi Object的互换
最新推荐文章于 2025-04-05 15:51:11 发布