You are not logged in.
In a JSON of variable form and depth there are some properties who are arrays of objects, like "fek" in the following example:
{
...
"extraFieldValues": {
"fek": [
{
"aa": "",
"issue": "",
"issueyear": ""
}
],
...
}
I have a PDocVariantData pointer pointing to "fek" and I want to add one more object in the array. However I can't use the AddItem method, because it requires a variant as parameter, so the following line produces a compilation error with message "Incompatible types: 'Variant' and 'TDocVariantData'".
pdoc^.AddItem(pdoc^._[0]^);
Is there any way to typecast a TDocVariantData as a Variant and if not, how can I add to the "fek" array of the above example one more of its contained objects?
Offline
Thanks a lot! I had tried this typecast:
pdoc^.AddItem(Variant(pdoc^._[0]^));
but it raised a run time error with message "Invalid variant type".
After your message I used a local TDocVariantData variable, named docVData and it works!
docVData := pdoc^._[0]^;
pdoc^.AddItem(Variant(docVData));
Last edited by damiand (2019-02-24 14:28:34)
Offline
But I guess that for your demand, the cleanest is perhaps to write:
pdoc^.AddItem(pdoc^.Values[0]);
That was my initial thought and attempt, but it raises an EVariantBadVarTypeError exception with message 'Invalid variant type'.
Offline