You are not logged in.
Pages: 1
Hi All
I have SOA project working as expected. A call to the interface
returns the following.
{"rows":[{"ID":1,"Name":"BE10065","iData":{"name":"BE10065","D1":"D1","D2":"D2","D3":"D3","D4":"D4","D5":"D5","D6":"D6","D7":"D7","D8":"D8","D9":"D9","D10":"D10","D11":"D11","D12":"D12"}}]}
What function on the client side can parse the data in the variant array "iData"
Im guessing i should be using JsonGet(ObjColumn,'Obj1.Obj2.Prop') for this
I just cant work out how to use this on the client side. Any help will be appreciated
Offline
Easiest would be to use TDocVariantData and TDocVariant Variant, something like:
var
v: Variant;
rows, iData: TDocVariantData;
i: Integer;
begin
v := _JsonFast('{"rows":[{"ID":1,"Name":"BE10065","iData":{"name":"BE10065","D1":"D1","D2":"D2","D3":"D3","D4":"D4","D5":"D5","D6":"D6","D7":"D7","D8":"D8","D9":"D9","D10":"D10","D11":"D11","D12":"D12"}}]}');
rows := _Safe(v.rows)^;
for i := 0 to rows.Count - 1 do
begin
iData := _Safe(rows.Values[i].iData)^;
if iData.Count > 0 then
ShowMessage(iData.U['name'] + '; ' + iData.U['D1'] + '; ' + iData.U['D2'] + '; ');
end;
end;
Offline
Thanks Igors233
Thats exactly what I was after. Much appreciated will implement
Offline
Small tip: use PDocVariantData instead of TDocVariantData.
var rows, iData: PDocVariantData;
...
rows := _Safe(v.rows);
...
iData := _Safe(...);
Using pointers would make the code faster and safer, e.g. if you modify the data.
Online
Pages: 1