maxkleiner / maXbox4

code compiler script studio
GNU General Public License v3.0
23 stars 10 forks source link

JSON4maXbox #26

Closed maxkleiner closed 3 years ago

maxkleiner commented 3 years ago

Now there are 2 libs available json4delphi and uJson:

            procedure jsonobjectTest_compare;
             // from 1243 unit uPSI_uJSON2;
            var
              json: TJSONObject;   Jobj:  TJSONObject2;
              Text: String;
              i: Integer;
            begin
              json := TJSONObject.create4(jsonnames);
              for i:=0 to json.getJSONArray('Names').Length -1 do begin
                Text := json.getJSONArray('Names').getJSONObject(i).optString('FirstName');
                //...
                writeln(text)
              end;

              Jobj:= TJSONObject2.create(nil); 
              jobj.parse(jsonnames);
              for i:= 0 to Jobj.count+1 do          
                 writeln(jobj['Names'].asArray[i].asObject['FirstName'].asstring);    
              jObj.Free; 
              json.Free;
           end;
maxkleiner commented 3 years ago

Runs :+1: http://www.softwareschule.ch/examples/covidapp31.txt