#1 2014-12-04 16:30:39

itSDS
Member
From: Germany
Registered: 2014-04-24
Posts: 506

Missing RowCount in TJSONTable / TJSONTableObject

Hi AB,
if i use nonExpanded Format, the Last Value is RowCount.

ATM i'm missing this Property in TJSONTable.
or is it fast enough to use

JSONVariant(JSON).rowCount


Rad Studio 12.1 Santorini

Offline

#2 2014-12-04 18:03:53

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,206
Website

Re: Missing RowCount in TJSONTable / TJSONTableObject

AFAIR TJSONTable is parsing the content on the fly.
It does not use the "RowCount" indicator in non Expanded format.

But I guess that a

n := 0;
while table.Step do inc(n); 

Is slightly faster than JSONVariant(JSON)...
Even if not perfect.

Offline

#3 2014-12-05 12:31:06

itSDS
Member
From: Germany
Registered: 2014-04-24
Posts: 506

Re: Missing RowCount in TJSONTable / TJSONTableObject

TY, i took the first one. But Have one Problem with SeekFirst

Your code should read:

n := 0;
while table.Step(n=0) do inc(n); 

or

n := 0;
bSeekFirst := true;
while table.Step(bSeekFirst) do begin
  inc(n); 
  bSeekFirst := false;
end;

cause normally you have to SeekFirst smile

Could there be an more elegant way to do the SeekFirst ?

Normally in Delphi you do something like:

table.First
while not table.eof do
  table.Next;
end;

Both Versions hae their Advantages.

Last edited by itSDS (2014-12-05 12:33:03)


Rad Studio 12.1 Santorini

Offline

#4 2014-12-06 11:38:18

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,206
Website

Re: Missing RowCount in TJSONTable / TJSONTableObject

Or just write:

n := 0;
if table.Step(true) then
repeat
  inc(n);
until not table.Step;

smile

Offline

Board footer

Powered by FluxBB