#1 2014-08-19 01:55:48

bigheart
Member
Registered: 2014-08-01
Posts: 45

How to directly access to TDocVariant variable

Hello!

I got some document from MongoDB to TDocVariant like below:

[{"_id":{"$oid":"53D75BD3ACD063FD19EA3250"}, "STime":{"$date":"2014-08-18T08:30:30"}, "V1":"1", "V2":"2"}]

I could get the data "1" at TDocvariant variable Doc.V1 and i want to direct access the value as Doc.Value[x] for "V1".

but i have got error message:

"Variant method calls not supported"

What could i do access the value using index?

Offline

#2 2014-08-19 04:17:03

bigheart
Member
Registered: 2014-08-01
Posts: 45

Re: How to directly access to TDocVariant variable

I'm so messy!.

Lutf8: RawUtf8;
Doc2: variant;
...
LUtf8 := VariantSaveJSon(Doc);
Doc2 := _Json(Lutf8);
writeln(Doc2.Value(2));  //<--V1's value 1 is displayed

but,

i := 2;
writeln(Doc2.Value(i));  //<-- Variant method calls not supported

The result is different when constant 2 and variable i for Doc2.value(x).

Please give me some hint.

Last edited by bigheart (2014-08-19 04:33:57)

Offline

#3 2014-08-19 06:26:09

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

Re: How to directly access to TDocVariant variable

Safer is to use directly TDocVariant here and not a variant.

Offline

Board footer

Powered by FluxBB