TSQLTableJSON解析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;