unit Unit4; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls; type TForm4 = class(TForm) btn1: TButton; Memo1: TMemo; lbl1: TLabel; btn2: TButton; procedure btn1Click(Sender: TObject); procedure btn2Click(Sender: TObject); private { Private declarations } public { Public declarations } end; /// <summary> /// Novice note, must be defined in the above implementation keywords. // / </ Summary> type TRenLei = Record name: String ; Age: Integer; Sex: Boolean; End ; var Form4: TForm4; implementation { $ R & lt *. DFM } uses qjson; Procedure TForm4.btn1Click (Sender: TObject); var ARenLei: TRenLei; MyQj: TQJson; the begin MyQj: . = TQJson the Create ; the try // this example better understood ARenLei.name: = ' Obama ' ; ARenLei.age := 1; ARenLei.sex := True; MyQj.FromRecord<TRenLei>(ARenLei); Memo1.Lines.Clear; Memo1.Lines.Add(MyQj.AsJson); finally MyQj.Free; end; end; procedure TForm4.btn2Click(Sender: TObject); var RenLeiArray: TArray<TRenLei>; MyQj: TQJson; begin MyQj := TQJson.Create; try SetLength(RenLeiArray,2); with RenLeiArray[0] do the begin (RenLeiArray); name: = ' Biden ' ; Age: = . 1 ; Sex: = True; End ; with RenLeiArray [ . 1 ] do the begin name: = ' Hillary ' ; Age: = 2 ; Sex: = False; End ; // here is not well understood, I do not understand, here TArray <TRenLei> can be converted to a generic array Json, please leave a message and who knows the principles below. MyQj.FromRecord <TArray <TRenLei >> Memo1.Lines.Clear; Memo1.Lines.Add (MyQj.AsJson); finally MyQj.Free; end; end; end.
Transfer from: http: //blog.qdac.cc/ p = 4189?