You are not logged in.
Pages: 1
Hi AB atm we encounter a serious(german: merkwürdig) Problem using TDocVariant
var
doc : variant;
begin
TDocVariant.New(doc);
doc.Fehler := _Obj([]);
doc.Fehler.Add('testfehler', true);
assert(doc.fehler.testfehler = true, 'Fehler mit TDocVariant');
end;
On my developer Computer it works. Now we startet the programm in another computer and the assertion fails.
the Value of doc.fehler.testfehler is false
Very serious is that i get this error also sometimes in my debugger. But i didn't find the reason for this.
May you can help if you tell me how to debug it or where i have to set a breakpoint to inspect code.
Best Regards
Rad Studio 12.1 Santorini
Offline
Solved the Problem with a cast:
DocVariantData(doc.fehler).AddValue('testfehler', true);
I found something about pseudo methods in syncommons.pas - But it seem's not to work in release mode on XE7 ?!
Rad Studio 12.1 Santorini
Offline
DocVariantData or DocVariantDataSafe will always be faster than late binding.
Of course, the following sounds safer and better:
doc.Fehler := _Obj(['testfehler',true]);
Or even
doc.Fehler := _Obj([]);
doc.Fehler.testfehler := true;
But there was some random issue with parameters when using late-binding for Unicode Version of Delphi.
Even Delphi 2007 is failing passing the value... and doc.Fehler.Add('testfehler', '3') will just trigger an OutOfMemory error!
The pseudo-methods are indeed pretty unstable...
I'm afraid this is not an issue with SynCommons, but with the Delphi RTL itself...
Online
Hi AB ty for your response.
we'll use DocVariantData now to Add Values. Cause we have to Add multiple Values to doc.fehler we have to call the AddValue direkt.
I havent't digged as deep as you in the RTL but would it be more Safe to remove the Pseudo - Functions ?
Rad Studio 12.1 Santorini
Offline
Something that I couldn't understand:
var
LDocVariant: variant;
begin
LDocVariant := _JsonFast('{ "Person": { "First": { "name" : "Alex" } } }');
LDocVariant.Person.Next := _ObjFast(['age', 31]); // this does not work for me
expected output:
{"Person":{"First":{"name":"Alex"},"Next":{"age":31}}}
--------------------------------------------------------------------------------
LDocVariant := _Json('{"name":?,"year":?}',[],['warleyalex',1982]); //this does not work - Ordinal type required
expected output:
{"name":"warleyalex","year":1982}
Offline
a) to add a JSON object content {"age":31} into {"Person":{"First":{"name":"Alex"}}} is works fine if you assign LDocVariant.Person.Next := LDocVariant1;
b) to produce valid JSON content from a given set of values identified by ? is better use _JsonFmt.
Offline
Pages: 1