Summary
Value method allows to serialize typed data value. Both, simple types, such as Integer or string, and complex types, such as records, objects or arrays can be serialized using Value method.
Syntax
procedure Value<T>(const V: T);
Type Parameters
- T
- Specifies type of serializing value.
Parameters
- V
Type: T
Specifies value to serialize.
Remarks
Value method should be used to serialize typed data values. It can be called in the following serializer states:
- Right after a specialized serializer has been created the Value method can be called any times to serialize one or more root values. Some specialized serializers, which generate human readable output documents may require to specify a name for a root-level value using additional serializer's API. Note, that root-level values naming is not a part of core serializer API.
- After NG.Serialization.TSerializer.BeginArray(string) and before corresponding NG.Serialization.TSerializer.EndArray method calls Value method can be called any time to serialize array elements.
- Inside an object serialization initiated by NG.Serialization.TSerializer.BeginObject(string,Boolean) method call, the Value method can be called one time after NG.Serialization.TSerializer.Prop(string) method call to specify serializing property value.
- Writing custom converter, descending a class from TConverter base class.
- Using low-level methods, such as NG.Serialization.TSerializer.BeginObject(string,Boolean)/ NG.Serialization.TSerializer.Prop(string)/NG.Serialization.TSerializer.EndObject, NG.Serialization.TSerializer.BeginArray(string)/NG.Serialization.TSerializer.EndArray, NG.Serialization.TSerializer.Null, to serialize your data manually.
Examples
Delphi | Copy Code |
---|---|
S.Value<string>('Some string'); S.Value<Integer>(7); S.Value<TMyCustomer>(customer); |