Tsqltablejson parsing JSON
Uses Mormot
Rocedure ttesttablecontent.synopsetablevariant;
var Json:rawutf8;
People:variant;
List:tsqltablejson;
Begin
JSON: = stringFromFile (Ffilename);
Owner.TestTimer.Start;
List: = Tsqltablejson.create (' ', Pointer (JSON), Length (JSON));
While list. Step (False, @people) do begin
Check (people. Firstname<> ");
Check (people. Lastname<> ");
Check (people. yearofbirth<10000);
Check ((People. yearofdeath>1400) and (people. yearofdeath<2000));
Check ((people.id>11011) or (people. Data<> "));
End
Frunconsoleoccurencenumber: = list. RowCount;
frunconsolememoryused: = Memoryused-fmemoryatstart;
List. Free;
End
Procedure Ttesttablecontent.synopsetableindex;
var Json:rawutf8;
List:tsqltablejson;
I:integer;
Begin
JSON: = stringFromFile (Ffilename);
Owner.TestTimer.Start;
List: = Tsqltablejson.create (' ', Pointer (JSON), Length (JSON));
For I: = 1 to list. RowCount DO begin
Check (list. Get (i, ' FirstName ') <>nil);
Check (list. Get (i, ' LastName ') <>nil);
Check (list. Getasinteger (i, ' Yearofbirth ') <10000);
Check (list. Getasinteger (i, ' Yearofdeath ') >1400) and (list. Getasinteger (i, ' Yearofdeath ') <2000));
Check (list. Getasinteger (i, ' RowID ') >11011) or (list. Get (i, ' Data ') <>nil));
End
Frunconsoleoccurencenumber: = list. RowCount;
frunconsolememoryused: = Memoryused-fmemoryatstart;
List. Free;
End
Tsqltablejson parsing JSON