#1 2021-07-24 14:06:27

danielkuettner
Member
From: Germany
Registered: 2014-08-06
Posts: 330

Count of Names/Values of TDocVariantData

mORMot.core.variants set length to 16 (although real number of fields in json is lower e.g. 11).
Is it an error when Length(TDocVariantData.Names)-1 or High(TDocVariantData.Names) gives 15 or isn't it allowed to access Names/Values with mORMot2?

Last edited by danielkuettner (2021-07-24 14:17:55)

Offline

#2 2021-07-24 16:52:14

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

Re: Count of Names/Values of TDocVariantData

This length is the capacity.

    /// direct acces to the low-level internal array of values
    // - note that length(Values)=Capacity and not Count, so copy(Values, 0, Count)
    // or use FieldValues iterator if you want the exact count
....
    /// direct acces to the low-level internal array of names
    // - is void (nil) if Kind is not dvObject
    // - note that length(Names)=Capacity and not Count, so copy(Names, 0, Count)
    // or use FieldNames iterator if you want the exact count

Use the Count property for the number of values.

Offline

#3 2021-07-30 08:03:19

flydev
Member
From: France
Registered: 2020-11-27
Posts: 49
Website

Re: Count of Names/Values of TDocVariantData

Yes, you must use

TDocVariantData.Names._Count - 1

Offline

Board footer

Powered by FluxBB