Summary

BeginArray method is a low-level method, which allows to serialize array like data manually. Every call to BeginArray method should be matched by a call to NG.Serialization.TSerializer.EndArray method.

Syntax

procedure BeginArray(const AElemName: string); overload;

Parameters

AElemName

Type: string

Specified element name for array element values, which is used to name array element values in some human readable output formats. For example, TXmlSerializer uses this string as a tag for array element nodes.

Remarks

To serialize array data, usually there are no need to use BeginArray method, the real Delphi array can be serialized using a single call to Value method:

DelphiCopyCode imageCopy Code
S.Value<TMyArray>(MyArray);
However, there are cases, when the data is not physically stored in array. In such cases its possible to serialize array like data manually, using BeginArray/NG.Serialization.TSerializer.EndArray low-level methods. After a call to BeginArray, array elements should be serialized one by one; when all array elements was serialized a call to NG.Serialization.TSerializer.EndArray must be made.  An array element can be serialized using one of the following ways:

Examples

DelphiCopyCode imageCopy Code
S.BeginArray('Number');
S.Value<Integer>(1);
S.Value<Integer>(1);S.Value<Integer>(2);
S.Value<Integer>(3);
S.Value<Integer>(5);
S.EndArray;