Freigeben über


CborReader.ReadStartMap Method

Definition

Reads the next data item as the start of a map (major type 5).

public:
 Nullable<int> ReadStartMap();
public int? ReadStartMap ();
member this.ReadStartMap : unit -> Nullable<int>
Public Function ReadStartMap () As Nullable(Of Integer)

Returns

The number of key-value pairs in a definite-length map, or null if the map is indefinite-length.

Exceptions

The next data item does not have the correct major type.

The next value has an invalid CBOR encoding.

-or-

There was an unexpected end of CBOR encoding data.

-or-

The next value uses a CBOR encoding that is not valid under the current conformance mode.

Remarks

Map contents are consumed as if they were arrays twice the length of the map's declared size. For instance, a map of size 1 containing a key of type Int32 with a value of type String must be consumed by successive calls to ReadInt32() and ReadTextString(). It is up to the caller to keep track of whether the next value is a key or a value. Fundamentally, this is a technical restriction stemming from the fact that CBOR allows keys of arbitrary type, for instance a map can contain keys that are maps themselves.

Applies to