You are not logged in.
Pages: 1
I'm having issues with commits from this year (year ago version was OK) in TDocVariantData. What I do is load json content into variablse, then use values from these variables to fill another one that gets sent to client. After that I lose values in initially loaded variable (they become null). I've tested in XE7 and D7 with same result.
I've managed to find a reproducible simple case, you can download it from this link: www.dropbox.com/s/5w6n5o2xvp4toie/Test.zip?dl=0 and here are some sample code:
const
JSON_TEST_DOC = '[{"Field1":"Value1_1", "Field2":"Value2_1"}, ' +
'{"Field1":"Value1_2", "Field2":"Value2_2"},' +
'{"Field1":"Value1_3", "Field2":"Value2_3"}]';
var
FItems: TDocVariantData;
procedure TfrmMain.DoTest;
var
doc, docItems: TDocVariantData;
i: Integer;
begin
FItems.InitJSON(JSON_TEST_DOC, JSON_OPTIONS[False]);
doc.Init(JSON_OPTIONS[False]);
docItems.Init(JSON_OPTIONS[False]);
doc.AddValue('Test', '');
for i := 0 to FItems.Count - 1 do
docItems.AddItem(_Arr([FItems.Values[i].Field1, FItems.Values[i].Field2]));
doc.AddValue('Itms', Variant(docItems));
AddToDisplay(doc.ToJSON);
end;
After code executes FItems will be: [{"Field1":null,"Field2":null},{"Field1":null,"Field2":null},{"Field1":null,"Field2":null}]
Am I missing something, not using it property, has TDocVariantData changed from earlier?
Last edited by igors233 (2016-04-04 19:54:29)
Offline
Thanks to your code to reproduce the issue, I found out that _ArrFast() instead of _Arr() did work as expected.
There was an issue with parameters passing when TDocVariant values were not passed by reference.
Should be fixed by http://synopse.info/fossil/info/a18d43e9e7
Offline
Thanks, I've tried and it's working fine.
Offline
Pages: 1