unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; Button2: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); end; var Form1: TForm1; implementation {$R *.dfm} uses SuperObject; //SuperObject 提倡使用接口; ParseString 是 TSuperObject 类的 Class 方法 procedure TForm1.Button1Click(Sender: TObject); var jo: ISuperObject; begin jo := TSuperObject.ParseString('{"No1":"张三", "No2":"李四"}'); ShowMessage(jo['No1'].AsString); {张三} end; //有个共用函数 SO, 可方便实现接口 procedure TForm1.Button2Click(Sender: TObject); var jo: ISuperObject; begin jo := SO('{"No1":"张三", "No2":"李四"}'); ShowMessage(jo['No2'].AsString); //李四 end; end.
![](https://img2024.cnblogs.com/blog/35695/202408/35695-20240826070647288-243310440.jpg)