Delphi XE10 has a JSON-processing unit that introduces "System.json" in the cells you need to use JSON, and then you can use Delphi's own JSON processing classes.
Jsonstring = ' {
"_id": "4",
"Dev": "4",
"Type": "Physical",
"Math": {
"Consts": {
"CT": 1,
"PT": 1
},
"Exprs": {}
},
"Name": "Iron-Smelting # # Dust High Pressure room"
}‘
Procedure Tfrm_0201_dev. Act_f_020102_editexecute (Sender:tobject);
Var
Devobject,mathobj,contstsobj:tjsonobject; JSON class
smath,scontsts,sct,spt:string;
Begin
If Lv_dev. Selected=nil then raise Exception.create (' Please select Device ');
Dselector:=json ([' Dev ', Lv_dev. Selected.caption]);
D:=fmongowire.get (Devcol,dselector);
Devobject:=tjsonobject.parsejsonvalue (jsonstring) as Tjsonobject; Generating JSON from a string
Smath:=devobject.getvalue (' math '). ToString;
Mathobj:=tjsonobject.parsejsonvalue (Smath) as Tjsonobject;
Scontsts:=mathobj.getvalue (' consts '). ToString;
Contstsobj:=tjsonobject.parsejsonvalue (scontsts) as Tjsonobject;
SCT: = Contstsobj.getvalue (' CT '). ToString; Get CT
SPT: = Contstsobj.getvalue (' PT '). ToString;
Frm_020101_devadd.showmodal;
End
Property
Property Count:integer Read getcount;//to get the outermost data count
Example: Num:=devobject.count; Result is 5
So that regular data can be recycled.
Delphi Xe-system.json