Summary

Prop method allows to specify property name when serializing object properties.

Syntax

function Prop(const AName: string): TSerializer;

Parameters

AName

Type: string

The name of serializing property.

Return Value

Prop method always return the same serializer object. This allows to write S.Prop('MyProp').Value<Integer>(0) in a single line.

Remarks

Prop method calls are only possible while serializing object data manually; that is - after NG.Serialization.TSerializer.BeginObject(string,Boolean) and before corresponding NG.Serialization.TSerializer.EndObject method calls. The process of a property serialization should include two method calls: first, Prop method should be called to begin property and specify its name, and then, one of the methods which provides property value, should be called. The following methods can be called after Prop method to specify a property value:

Since Prop method return the same serializer object, usually the value providing method can be written just after the Prop method call at the same source code line:
DelphiCopyCode imageCopy Code
S.Prop('MyProp').Value<Integer>(0);
The above code example completely serializes 'MyProp' property.

Examples

DelphiCopyCode imageCopy Code
S.BeginObject('Customer', False);
  S.Prop('Name').Value<string>('Juana Aguirre');
  S.Prop('Address').BeginObject('', False);
    S.Prop('Counrty').Value<string>('ARGENTINA');
    S.Prop('PostalCode').Value<string>('C1070AAM');
  S.EndObject;
S.EndObject;