UnitUnit1;InterfaceusesWindows, Messages, sysutils, variants, Classes, Graphics, Controls, Forms, Dialogs, Stdctrls;typeTForm1 =class(Tform) Button1:tbutton; Button2:tbutton; Button3:tbutton;procedureButton1Click (Sender:tobject);procedureButton2click (Sender:tobject);procedureButton3click (Sender:tobject);End;varForm1:tform1;Implementation{$R *.DFM}usesSuperobject;//AddprocedureTform1.button1click (Sender:tobject);varJo:isuperobject; I:integer;beginJO: = tsuperobject.create; forI: =0 to 9 DoJo. i[' N '+ INTTOSTR (i)]: = i; ShowMessage (Jo. Asjson (True)); forI: =0 to 9 DoJo. s[' N '+ INTTOSTR (i)]: = IntToStr (i); ShowMessage (Jo. Asjson (True)); forI: =0 to 9 DoJo. b[' N '+ INTTOSTR (i)]: = ODD (i); ShowMessage (Jo. Asjson (True)); forI: =0 to 9 DoJo. d[' N '+ INTTOSTR (i)]: = I/2; ShowMessage (Jo. Asjson (True)); forI: =0 to 9 DoJo. o[' N '+ INTTOSTR (i)]: = SO (' {' A ': ' B '} '); ShowMessage (Jo. Asjson (True)); Jo. Clear; ShowMessage (Jo. Asjson (True));End;//Modify and deleteprocedureTform1.button2click (Sender:tobject);varJo:isuperobject; Str:string;beginJO: = SO (' {' Name ': ' Zhang San ', ' age ': '); ShowMessage (Jo. Asjson (False, false)); Jo. s[' Name '] :=' John Doe '; Jo. i[' age '] := -; ShowMessage (Jo. Asjson (False, false)); Jo. Delete (' age '); ShowMessage (Jo. Asjson (False, false)); Jo. d[' Size '] :=1.83; ShowMessage (Jo. Asjson (False, false));End;//tsuperarray, Delete, change and viewprocedureTform1.button3click (Sender:tobject);varJo,item:isuperobject; Ja:tsuperarray; I:integer; Str:string;beginJO: = SO (' {' Hobby ': [' programming ', ' playing Ball ']} '); ShowMessage (Jo. Asjson (False, false)); Jo. a[' Hobbies ']. ADD (SO (' watch TV ')); ShowMessage (Jo. Asjson (False, false)); JA: = Jo. a[' Hobbies ']; Ja. ADD (SO (' Swimming ')); ShowMessage (Jo. Asjson (False, false)); Ja. Insert (0, SO (' Sleep ')); ShowMessage (Jo. Asjson (False, false)); Ja. Delete (0); ShowMessage (Jo. Asjson (False, false)); Ja. d[0] :=3.14; ShowMessage (Jo. Asjson (False, false)); Ja. o[0]: = SO (' {} '); ShowMessage (Jo. Asjson (False, false)); STR: ="'; forI: =0 toJa. Length-1 Dostr: = Format ('%s%s ', [str, ja. S[i]]); ShowMessage (Trim (str)); STR: ="'; forIteminchjo[' Hobbies '] Dostr: = Format ('%s%s ', [str, item. Asstring]); ShowMessage (Trim (str)); Ja. Clear; ShowMessage (Jo. Asjson (False, false));End;End.
JSON Superobject (4): Add, Delete, change