首先在项目文件目录下添加superobject文件
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, superobject,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
btn1: TButton;
lbl1: TLabel;
procedure btn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
type
TEmployee = class
Name: string;
LastN: string;
Age: Integer;
end;
var
Form1: TForm1;
jo: ISuperObject;
jts: TSuperTableString;
implementation
{$R *.dfm}
procedure TForm1.btn1Click(Sender: TObject);
begin
jo := SO('{A:1, B:2, C:3, D:{x:4, y:5, z:6}}');
jts := jo.AsObject;
ShowMessage(IntToStr(jts.count)); // 4
ShowMessage(jts.GetNames.AsString); // ["D","C","B","A"]
ShowMessage(jts.GetValues.AsString); // [{"z":6,"y":5,"x":4},3,2,1]
jts := jo['D'].AsObject;
ShowMessage(IntToStr(jts.count)); // 3
ShowMessage(jts.GetNames.AsString); // ["z","y","x"]
ShowMessage(jts.GetValues.AsString); // [6,5,4]
end;